List of usage examples for java.util Objects requireNonNull
public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier)
From source file:edu.umich.oasis.common.SodaDescriptor.java
private SodaDescriptor(int kind, ComponentName definingClass, String methodName, List<String> paramTypes, boolean makeCopy) { if (kind != KIND_INSTANCE && kind != KIND_STATIC && kind != KIND_CTOR) { throw new IllegalArgumentException("Unknown kind " + kind); }/*from w ww . j av a 2 s . c o m*/ this.kind = kind; this.definingClass = Objects.requireNonNull(definingClass, "definingClass"); this.methodName = (kind != KIND_CTOR) ? Objects.requireNonNull(methodName, "methodName") : null; this.paramTypes = (paramTypes != null) ? Collections.unmodifiableList(makeCopy ? new ArrayList<>(paramTypes) : paramTypes) : Collections.<String>emptyList(); }
From source file:com.conwet.silbops.msg.UnadvertiseMsg.java
public UnadvertiseMsg(Advertise advertise, Advertise context) { super(MessageType.UNADVERTISE); this.advertise = Objects.requireNonNull(advertise, "Advertise is null"); this.context = Objects.requireNonNull(context, "Context is null"); uncovered = new HashSet<>(); }
From source file:edu.umich.flowfence.common.QMDescriptor.java
private QMDescriptor(int kind, ComponentName definingClass, String methodName, List<String> paramTypes, boolean makeCopy) { if (kind != KIND_INSTANCE && kind != KIND_STATIC && kind != KIND_CTOR) { throw new IllegalArgumentException("Unknown kind " + kind); }// www . ja v a2s. c o m this.kind = kind; this.definingClass = Objects.requireNonNull(definingClass, "definingClass"); this.methodName = (kind != KIND_CTOR) ? Objects.requireNonNull(methodName, "methodName") : null; this.paramTypes = (paramTypes != null) ? Collections.unmodifiableList(makeCopy ? new ArrayList<>(paramTypes) : paramTypes) : Collections.<String>emptyList(); }
From source file:com.qwazr.search.annotations.AnnotatedIndexService.java
/** * Create a new index service. A class with Index and IndexField annotations. * * @param indexService the IndexServiceInterface to use * @param indexDefinitionClass an annotated class *///from w w w. j a v a2s .com public AnnotatedIndexService(IndexServiceInterface indexService, Class<T> indexDefinitionClass) { Objects.requireNonNull(indexService, "The indexService parameter is null"); Objects.requireNonNull(indexDefinitionClass, "The indexDefinition parameter is null"); this.indexService = indexService; this.annotatedService = indexService instanceof AnnotatedServiceInterface ? (AnnotatedServiceInterface) indexService : null; this.indexDefinitionClass = indexDefinitionClass; Index index = indexDefinitionClass.getAnnotation(Index.class); Objects.requireNonNull(index, "This class does not declare any Index annotation: " + indexDefinitionClass); schemaName = index.schema(); indexName = index.name(); similarityClass = index.similarityClass(); Field[] fields = indexDefinitionClass.getDeclaredFields(); if (fields != null && fields.length > 0) { fieldMap = new HashMap<>(); indexFieldMap = new HashMap<>(); for (Field field : fields) { if (!field.isAnnotationPresent(IndexField.class)) continue; field.setAccessible(true); IndexField indexField = field.getDeclaredAnnotation(IndexField.class); String indexName = StringUtils.isEmpty(indexField.name()) ? field.getName() : indexField.name(); indexFieldMap.put(indexName, indexField); fieldMap.put(indexName, field); } } else { fieldMap = null; indexFieldMap = null; } }
From source file:org.apache.calcite.adapter.elasticsearch.ElasticsearchTable.java
/** * Creates an ElasticsearchTable./*from w ww .jav a 2 s . c o m*/ * @param client low-level ES rest client * @param mapper Jackson API * @param indexName elastic search index * @param typeName elastic searh index type */ ElasticsearchTable(RestClient client, ObjectMapper mapper, String indexName, String typeName) { super(indexName, typeName, Objects.requireNonNull(mapper, "mapper")); this.restClient = Objects.requireNonNull(client, "client"); try { this.version = detectVersion(client, mapper); } catch (IOException e) { final String message = String.format(Locale.ROOT, "Couldn't detect ES version " + "for %s/%s", indexName, typeName); throw new UncheckedIOException(message, e); } }
From source file:com.smokejumperit.gradle.report.DependencyLicenseReport.java
public void setReportedConfigurations(String reportedConfiguration) { Objects.requireNonNull(reportedConfiguration, "configuration to report"); this.reportedConfigurations = ImmutableList.of(reportedConfiguration); }
From source file:intelligent.wiki.editor.core_impl.sweble.SwebleASTNode.java
@Override public void addChild(ASTNode child) { if (this.equals(child)) { throw new IllegalArgumentException("Can not be child to yourself!"); }//from w w w . j a v a 2s.c o m Objects.requireNonNull(child, "Child node null!"); children.add(child); }
From source file:de.speexx.csv.table.CsvReader.java
/** Creates a new {@code CsvReader} for the given <em>reader</em>. * @param reader the reader to read the CSV content from * @throws NullPointerException if the given <em>reader</em> is {@code null} * @throws IOException if is not possible to init the reader. *//* w w w . ja va 2 s . c om*/ public CsvReader(final Reader reader) throws IOException { Objects.requireNonNull(reader, "reader is null"); this.reader = reader; this.ownReader = false; init(reader); }
From source file:com.navercorp.pinpoint.web.filter.RpcURLPatternFilter.java
public RpcURLPatternFilter(String urlPattern, ServiceTypeRegistryService serviceTypeRegistryService, AnnotationKeyRegistryService annotationKeyRegistryService) { this.urlPattern = Objects.requireNonNull(urlPattern, "urlPattern must not be null"); this.serviceTypeRegistryService = Objects.requireNonNull(serviceTypeRegistryService, "serviceTypeRegistryService must not be null"); this.annotationKeyRegistryService = Objects.requireNonNull(annotationKeyRegistryService, "annotationKeyRegistryService must not be null"); // TODO serviceType rpctype // TODO remove. hard coded annotation for compatibility, need a better to group rpc url annotations this.rpcEndpointAnnotationCodes = initRpcEndpointAnnotations(AnnotationKey.HTTP_URL.getName(), AnnotationKey.MESSAGE_QUEUE_URI.getName(), "thrift.url", "npc.url", "nimm.url"); }
From source file:com.steelbridgelabs.oss.neo4j.structure.Neo4JGraphConfigurationBuilder.java
private Neo4JGraphConfigurationBuilder(String hostname, short port, String username, String password) { Objects.requireNonNull(hostname, "hostname cannot be null"); Objects.requireNonNull(username, "username cannot be null"); Objects.requireNonNull(password, "password cannot be null"); // store fields this.hostname = hostname; this.port = port; this.username = username; this.password = password; }