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.facebook.presto.sql.analyzer.Field.java
public static Field newUnqualified(Optional<String> name, Type type) { Preconditions.checkNotNull(name, "name is null"); Preconditions.checkNotNull(type, "type is null"); return new Field(Optional.empty(), name, type, false); }
From source file:org.apache.james.webadmin.dto.CassandraVersionRequest.java
public static CassandraVersionRequest parse(String version) { Preconditions.checkNotNull(version, "Version is mandatory"); return new CassandraVersionRequest(Integer.valueOf(version)); }
From source file:com.salesforce.jprotoc.ProtoTypeMap.java
/** * Returns an instance of {@link ProtoTypeMap} based on the given {@link DescriptorProtos.FileDescriptorProto} * instances./*from ww w . ja va2s . co m*/ * * @param fileDescriptorProtos the full collection of files descriptors from the code generator request */ public static ProtoTypeMap of(@Nonnull Collection<DescriptorProtos.FileDescriptorProto> fileDescriptorProtos) { Preconditions.checkNotNull(fileDescriptorProtos, "fileDescriptorProtos"); Preconditions.checkArgument(!fileDescriptorProtos.isEmpty(), "fileDescriptorProtos.isEmpty()"); final ImmutableMap.Builder<String, String> types = ImmutableMap.builder(); for (final DescriptorProtos.FileDescriptorProto fileDescriptor : fileDescriptorProtos) { final DescriptorProtos.FileOptions fileOptions = fileDescriptor.getOptions(); final String protoPackage = fileDescriptor.hasPackage() ? "." + fileDescriptor.getPackage() : ""; final String javaPackage = Strings.emptyToNull( fileOptions.hasJavaPackage() ? fileOptions.getJavaPackage() : fileDescriptor.getPackage()); final String enclosingClassName = fileOptions.getJavaMultipleFiles() ? null : getJavaOuterClassname(fileDescriptor, fileOptions); fileDescriptor.getEnumTypeList().forEach(e -> types.put(protoPackage + "." + e.getName(), toJavaTypeName(e.getName(), enclosingClassName, javaPackage))); fileDescriptor.getMessageTypeList().forEach(m -> types.put(protoPackage + "." + m.getName(), toJavaTypeName(m.getName(), enclosingClassName, javaPackage))); } return new ProtoTypeMap(types.build()); }
From source file:com.google.security.zynamics.binnavi.API.helpers.TreeAlgorithms.java
/** * Tests whether a node dominates another node. * * @param node The node of the dominator tree where the search starts. * @param target The dominator node./*from w w w . j ava 2 s .c o m*/ * @param source The dominated node. * * @return True, if the dominator node dominates the dominated node. False, otherwise. */ public static <NodeType> boolean dominates(final ITreeNode<NodeType> node, final ITreeNode<NodeType> target, final ITreeNode<NodeType> source) { Preconditions.checkNotNull(node, "Error: Node argument can not be null"); Preconditions.checkNotNull(target, "Error: target argument can not be null"); Preconditions.checkNotNull(source, "Error: Source argument can not be null"); return com.google.security.zynamics.zylib.types.trees.TreeAlgorithms.dominates(node, target, source); }
From source file:org.apache.brooklyn.core.catalog.internal.CatalogItemBuilder.java
public static CatalogItemBuilder<?> newItem(CatalogItemType itemType, String symbolicName, String version) { Preconditions.checkNotNull(itemType, "itemType required"); switch (itemType) { case ENTITY:// www.ja v a 2 s . co m return newEntity(symbolicName, version); case TEMPLATE: return newTemplate(symbolicName, version); case POLICY: return newPolicy(symbolicName, version); case LOCATION: return newLocation(symbolicName, version); } throw new IllegalStateException("Unexpected itemType: " + itemType); }
From source file:com.marand.thinkmed.medications.TherapyTaggingUtils.java
public static String generateSourceTag(@Nonnull final String sourceId) { Preconditions.checkNotNull(sourceId, "sourceId"); return TherapyTagEnum.SOURCE.getPrefix() + sourceId; }
From source file:org.retrostore.android.view.ImageLoader.java
public static ImageLoader get(Context ctx) { return new ImageLoader(Preconditions.checkNotNull(ctx, "Context cannot be null"), Executors.newCachedThreadPool()); }
From source file:fr.norad.visuwall.plugin.hudson.States.java
public static final BuildState asVisuwallState(String hudsonState) { Preconditions.checkNotNull(hudsonState, "hudsonState is mandatory"); hudsonState = hudsonState.toLowerCase(); BuildState state = STATE_MAPPING.get(hudsonState); if (state == null) { state = BuildState.UNKNOWN; LOG.warn(hudsonState + " is not available in Hudson plugin. Please report it to Visuwall dev team."); }//from w w w .j a v a 2 s .c o m return state; }
From source file:org.apache.usergrid.persistence.index.utils.IndexValidationUtils.java
/** * Validate the search edge is correct/*from w ww . j a v a2 s.c o m*/ * @param searchEdge */ public static void validateSearchEdge(final SearchEdge searchEdge) { Preconditions.checkNotNull(searchEdge, "searchEdge is required"); org.apache.usergrid.persistence.core.util.ValidationUtils.verifyIdentity(searchEdge.getNodeId()); Preconditions.checkArgument(searchEdge.getEdgeName() != null && searchEdge.getEdgeName().length() > 0, "search edge name is required"); }
From source file:org.eclipse.sirius.tests.swtbot.support.api.matcher.WithSemantic.java
/** * Get a default {@link WithSemantic}./* w ww . j a v a 2 s . c o m*/ * * @param semantic * for which get a associated Bot * * @return a default {@link WithSemantic} */ public static Matcher<EditPart> withSemantic(EObject semantic) { Preconditions.checkNotNull(semantic, "Can't execute this matcher on a null semantic elt"); return new WithSemantic(semantic); }