List of usage examples for com.google.common.base Preconditions checkNotNull
public static <T> T checkNotNull(T reference, @Nullable Object errorMessage)
From source file:com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.editmode.helpers.CTooltipUpdater.java
/** * Determines whether a given node is a proximity node. * // w w w .j ava 2 s.c om * @param graph The graph the node belongs to. * @param node The node to check. * * @return True, if the node is a proximity node. False, otherwise. */ public static boolean isProximityNode(final AbstractZyGraph<?, ?> graph, final Node node) { Preconditions.checkNotNull(graph, "Graph argument can not be null"); Preconditions.checkNotNull(node, "Node argument can not be null"); return graph.getGraph().getRealizer(node) instanceof ZyProximityNodeRealizer<?>; }
From source file:com.google.security.zynamics.binnavi.ZyGraph.Implementations.CEdgeDrawingFunctions.java
/** * Calculates whether edges are drawn in sloppy mode or normal node. * * @param graph The graph for which the result is calculated. * * @return True, if edges are drawn in sloppy mode. *//*from w w w .jav a 2s . c om*/ public static boolean calcDrawSloppyEdges(final ZyGraph graph) { Preconditions.checkNotNull(graph, "IE02113: Graph argument can not be null"); final EdgeHidingMode mode = graph.getSettings().getEdgeSettings().getEdgeHidingMode(); return (mode == EdgeHidingMode.HIDE_NEVER) || ((mode == EdgeHidingMode.HIDE_ON_THRESHOLD) && (graph.getSettings().getEdgeSettings().getEdgeHidingThreshold() > graph.getEdgeCount())); }
From source file:io.airlift.airship.shared.MavenCoordinates.java
public static MavenCoordinates fromConfigGAV(String configSpec) { Preconditions.checkNotNull(configSpec, "configSpec is null"); if (!configSpec.startsWith("@")) { return null; }//from ww w . jav a 2s . co m configSpec = configSpec.substring(1); return fromGAV(configSpec, DEFAULT_CONFIG_PACKAGING); }
From source file:com.github.jeluard.guayaba.util.concurrent.ConcurrentMaps.java
/** * Returns value associated with key if exists. * Otherwise create value using provided {@link Supplier}, insert it map then returns it. * * TODO improve based on http://blog.boundary.com/2011/05/ * * @param <K>//from w w w .j a v a 2 s . c om * @param <V> * @param concurrentMap * @param key * @param supplier * @return previous value if exists; result of {@link Supplier#get()} otherwise */ public static synchronized <K, V> V putIfAbsentAndReturn(final ConcurrentMap<K, V> concurrentMap, final K key, final Supplier<V> supplier) { Preconditions.checkNotNull(concurrentMap, "null concurrentMap"); Preconditions.checkNotNull(key, "null key"); Preconditions.checkNotNull(supplier, "null supplier"); if (concurrentMap.containsKey(key)) { return concurrentMap.get(key); } final V value = supplier.get(); concurrentMap.put(key, value); return value; }
From source file:com.twitter.finagle.common.base.MorePreconditions.java
/** * Checks that a string is both non-null and non-empty. * * @see #checkNotBlank(String, String, Object...) *//*from w w w . jav a 2 s . c o m*/ public static String checkNotBlank(String argument) { Preconditions.checkNotNull(argument, ARG_NOT_BLANK_MSG); Preconditions.checkArgument(!StringUtils.isBlank(argument), ARG_NOT_BLANK_MSG); return argument; }
From source file:com.marand.thinkmed.medications.task.TherapyTaskUtils.java
public static List<String> getPatientIdKeysForTaskTypes(@Nonnull final Set<String> patientIdsSet, @Nonnull final Set<TaskTypeEnum> taskTypesSet) { Preconditions.checkNotNull(patientIdsSet, "patientIdsSet is null"); Preconditions.checkNotNull(taskTypesSet, "taskTypesSet is null"); final List<String> patientIdKeys = new ArrayList<>(); for (final String patientId : patientIdsSet) { Preconditions.checkNotNull(patientId, "patientId is null"); for (final TaskTypeEnum taskType : taskTypesSet) { Preconditions.checkNotNull(taskType, "taskType is null"); patientIdKeys.add(taskType.buildKey(patientId)); }/*from w w w . j av a2 s.com*/ } return patientIdKeys; }
From source file:com.outerspacecat.openid.rp.SessionType.java
/** * Returns whether or not {@code value} represents a session type. * //w w w . j av a2s .c o m * @param value the value to test. Must be non {@code null}. * @return whether or not {@code value} represents a session type */ static boolean isValidValue(final String value) { Preconditions.checkNotNull(value, "value required"); return value.equalsIgnoreCase(NO_ENCRYPTION.getValue()) || value.equalsIgnoreCase(DH_SHA1.getValue()) || value.equalsIgnoreCase(DH_SHA256.getValue()); }
From source file:com.aestasit.markdown.slidery.Slidery.java
public static String toSlides(RootNode node) { Preconditions.checkNotNull(node, "astRoot"); return getConverter().toHtml(node); }
From source file:com.google.security.zynamics.binnavi.Gui.GraphWindows.BottomPanel.RegisterTracker.CResultText.java
/** * Determines the description text used to display a given instruction. * * @param startInstruction Start instruction of the tracking operation. * @param trackedRegister The tracked register. * @param result Result of the tracking operation. * * @return Description text used to display the result instruction. *///from w w w . jav a2 s. c o m public static String determineDescription(final INaviInstruction startInstruction, final String trackedRegister, final CInstructionResult result) { Preconditions.checkNotNull(startInstruction, "IE01680: Start instruction argument can not be null"); Preconditions.checkNotNull(trackedRegister, "IE01681: Tracked register argument can not be null"); Preconditions.checkNotNull(result, "IE01682: Result argument can not be null"); if (result.getInstruction() == startInstruction) { return "Start"; } else if (result.undefinesAll()) { // This is the text for instructions that undefine all tracked // registers and therefore end the register tracking for one // code execution path. return "Clears all effects"; } else if (result.clearsTrackedRegister(trackedRegister)) { // This is the text used for instructions that undefined the // tracked register but do not undefine all tracked registers. return "Clears tracked register"; } else if (result.undefinesSome()) { // This is the text used for instructions that undefine some // tracked registers but not the originally tracked register. return "Clears some effects"; } else if (result.defines()) { // This is the text used for instructions that do not undefine // any registers but use any of the tracked registers. return "Depends on tracked register"; } else if (result.updates()) { // This is the test used for instructions that update any of // the tainted registers with new information. return "Updates tainted register"; } else if (result.uses()) { // This is the text used for instructions that read any of // the tainted registers. return "Reads tainted register"; } else { return ""; } }
From source file:org.opendaylight.controller.cluster.datastore.identifiers.ShardTransactionIdentifier.java
public ShardTransactionIdentifier(String remoteTransactionId) { this.remoteTransactionId = Preconditions.checkNotNull(remoteTransactionId, "remoteTransactionId should not be null"); }