List of usage examples for com.google.common.base Preconditions checkNotNull
public static <T> T checkNotNull(T reference, @Nullable Object errorMessage)
From source file:org.retrostore.ui.JspUtils.java
public static void writeResponse(ServletContext context, HttpServletRequest request, HttpServletResponse response, String path, TemplateModel model) throws ServletException, IOException { Preconditions.checkNotNull(context, "Context necessary"); Preconditions.checkNotNull(request, "RequestData necessary"); Preconditions.checkNotNull(response, "Response necessary"); Preconditions.checkNotNull(path, "Path necessary"); if (model == null) { model = new TemplateModel(); }/*from w ww . ja va 2s. com*/ request.setAttribute("model", model.getData()); context.getRequestDispatcher(path).forward(request, response); }
From source file:com.facebook.presto.sql.analyzer.Field.java
public static Field newUnqualified(String name, Type type) { Preconditions.checkNotNull(name, "name is null"); Preconditions.checkNotNull(type, "type is null"); return new Field(Optional.empty(), Optional.of(name), type, false); }
From source file:works.chatterbox.chatterbox.events.ChatterboxEvent.java
protected static HandlerList getHandlerList(@NotNull final String name) { Preconditions.checkNotNull(name, "name was null"); return ChatterboxEvent.handlerLists.getUnchecked(name); }
From source file:talkeeg.httpserver.HandlerPrefixLenFunctions.java
public static Function<String, Integer> from(final String prefix) { Preconditions.checkNotNull(prefix, "prefix is null"); return new Function<String, Integer>() { @Override/*from w w w .jav a 2 s .co m*/ public Integer apply(String input) { return input.startsWith(prefix) ? prefix.length() : -1; } }; }
From source file:com.github.jeluard.guayaba.base.Pairs.java
/** * @param <U>/* w w w. jav a2 s .c om*/ * @param <V> * @param pairs * @return a {@link Map} composed of all {@code pairs} element */ public static <U, V> Map<U, V> toMap(final Collection<Pair<U, V>> pairs) { Preconditions.checkNotNull(pairs, "null pairs"); final Map<U, V> map = new HashMap<U, V>(pairs.size()); for (final Pair<U, V> pair : pairs) { map.put(pair.first, pair.second); } return map; }
From source file:de.flapdoodle.guava.Expectations.java
private static <T> Optional<T> intNoneOrOne(Iterator<T> iterator) { Preconditions.checkNotNull(iterator, "iterator is null"); if (!iterator.hasNext()) { return Optional.absent(); }/*from w ww .ja v a 2 s. co m*/ return Optional.of(iterator.next()); }
From source file:com.github.jcustenborder.kafka.connect.utils.config.validators.Validators.java
/** * Method will return a validator that will accept a blank string. Any other value will be passed * on to the supplied validator./* ww w. ja v a 2 s . com*/ * * @param validator Validator to test non blank values with. * @return */ public static Validator blankOr(Validator validator) { Preconditions.checkNotNull(validator, "validator cannot be null."); return BlankOrValidator.of(validator); }
From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.Implementations.CGraphFreezer.java
/** * Toggles the state of Frozen/Editable in the graph. * * @param graph Graph to be frozen or unfrozen. *//*w w w . j a va2 s . c om*/ public static void toogleProximityFrozen(final ZyGraph graph) { Preconditions.checkNotNull(graph, "IE01739: Graph argument can not be null"); graph.getSettings().getProximitySettings().setProximityBrowsingFrozen( !graph.getSettings().getProximitySettings().getProximityBrowsingFrozen()); }
From source file:tv.icntv.grade.film.utils.ReflectionUtils.java
public static Object newInstance(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException { Preconditions.checkNotNull(null != className, "class name null"); return classLoader.loadClass(className).newInstance(); }
From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.Implementations.CGraphMagnifier.java
/** * Toggles the magnifying mode of a graph. * * @param graph The graph where the magnifying mode is toggled. *//* w ww .j av a 2 s .c om*/ public static void toogleMagnifyingGlass(final ZyGraph graph) { Preconditions.checkNotNull(graph, "IE01749: Graph argument can not be null"); graph.getSettings().getDisplaySettings() .setMagnifyingGlassMode(!graph.getSettings().getDisplaySettings().getMagnifyingGlassMode()); }