Example usage for java.util Objects requireNonNull

List of usage examples for java.util Objects requireNonNull

Introduction

In this page you can find the example usage for java.util Objects requireNonNull.

Prototype

public static <T> T requireNonNull(T obj, Supplier<String> messageSupplier) 

Source Link

Document

Checks that the specified object reference is not null and throws a customized NullPointerException if it is.

Usage

From source file:it.reply.orchestrator.dto.deployment.CredentialsAwareSlaPlacementPolicy.java

public void setUsername(String username) {
    Objects.requireNonNull(username, "username list must not be null");
    this.username = username;
}

From source file:com.github.horrorho.inflatabledonkey.requests.EscrowProxyRequestFactory.java

EscrowProxyRequestFactory(String dsPrsID, String mmeAuthToken, String escrowProxyUrl,
        Map<Headers, Header> headers) {
    this.dsPrsID = Objects.requireNonNull(dsPrsID, "dsPrsID");
    this.mmeAuthToken = Objects.requireNonNull(mmeAuthToken, "mmeAuthToken");
    this.escrowProxyUrl = Objects.requireNonNull(escrowProxyUrl, "escrowProxyUrl");
    this.headers = new HashMap<>(headers);
}

From source file:com.github.horrorho.inflatabledonkey.args.PropertyLoader.java

public PropertyLoader(Supplier<Map<Option, Property>> optionKeyMapSupplier) {
    this.optionKeyMapSupplier = Objects.requireNonNull(optionKeyMapSupplier, "optionKeyMapSupplier");
}

From source file:org.elasticsearch.test.rest.yaml.ClientYamlDocsTestClient.java

public ClientYamlTestResponse callApi(String apiName, Map<String, String> params, HttpEntity entity,
        Map<String, String> headers) throws IOException {

    if ("raw".equals(apiName)) {
        // Raw requests are bit simpler....
        Map<String, String> queryStringParams = new HashMap<>(params);
        String method = Objects.requireNonNull(queryStringParams.remove("method"),
                "Method must be set to use raw request");
        String path = "/" + Objects.requireNonNull(queryStringParams.remove("path"),
                "Path must be set to use raw request");
        // And everything else is a url parameter!
        try {/*from ww  w.  j a v a  2  s .  c om*/
            Response response = restClient.performRequest(method, path, queryStringParams, entity);
            return new ClientYamlTestResponse(response);
        } catch (ResponseException e) {
            throw new ClientYamlTestResponseException(e);
        }
    }
    return super.callApi(apiName, params, entity, headers);
}

From source file:com.codealot.textstore.FileStore.java

/**
 * Create a FileStore based on the given directory.
 * //ww w.j a  v  a  2s .  c om
 * @param storeRoot
 *            must be a directory
 */
public FileStore(final Path storeRoot) {
    Objects.requireNonNull(storeRoot, "Storage path not given.");

    if (!Files.isDirectory(storeRoot)) {
        throw new IllegalArgumentException("Path " + storeRoot + " is not a directory.");
    }
    this.storeRoot = storeRoot.toString();
}

From source file:de.unentscheidbar.validation.builtin.FilePropertiesValidator.java

public static FilePropertiesValidator instance(Type type) {

    Objects.requireNonNull(type, "type");
    return INSTANCES.get(type);
}

From source file:io.fabric8.quickstarts.camel.infinispan.InfinispanAutoConfiguration.java

/**
 * Defines a bean named 'remoteCacheContainer' that points to the remote Infinispan cluster.
 *//* w  w  w  . j  a v a2  s .co  m*/
@Bean(initMethod = "start", destroyMethod = "stop")
public BasicCacheContainer remoteCacheContainer(Environment environment) {

    String serviceBaseName = service.toUpperCase().replace("-", "_");
    String host = environment.getProperty(serviceBaseName + "_SERVICE_HOST");
    String port = environment.getProperty(serviceBaseName + "_SERVICE_PORT");
    Objects.requireNonNull(host, "Infinispan service host not found in the environment");
    Objects.requireNonNull(port, "Infinispan service port not found in the environment");

    String hostPort = host + ":" + port;
    logger.info("Connecting to the Infinispan service at {}", hostPort);

    ConfigurationBuilder builder = new ConfigurationBuilder().forceReturnValues(true).addServers(hostPort);

    return new RemoteCacheManager(builder.create(), false);
}

From source file:com.github.horrorho.inflatabledonkey.chunk.store.disk.DiskChunk.java

DiskChunk(byte[] checksum, Path file) {
    this.file = Objects.requireNonNull(file, "file");
    this.checksum = Arrays.copyOf(checksum, checksum.length);
}

From source file:com.wavemaker.tools.apidocs.tools.parser.config.SwaggerConfiguration.java

private SwaggerConfiguration(Builder builder) {
    this.baseUrl = builder.baseUrl;
    this.parameterResolvers = builder.parameterResolvers;
    this.modelScanner = builder.modelScanner;
    this.collectionFormat = builder.collectionFormat;
    this.schemes = builder.schemes;
    this.editable = builder.editable;
    this.info = builder.info;
    this.classLoader = Objects.requireNonNull(builder.classLoader, "Class loader should not be null");
    this.classScanner = Objects.requireNonNull(builder.classScanner, "Class scanner should not be null");
}

From source file:com.diffplug.gradle.pde.PdeProductBuildConfig.java

void setup(File destinationDir, PdeBuildProperties props, List<SwtPlatform> platforms, List<File> pluginPaths)
        throws IOException {
    // make sure every required entry was set
    Objects.requireNonNull(id, "Must set `id`");
    Objects.requireNonNull(productPluginDir, "Must set `productPluginDir`");
    Objects.requireNonNull(productFileWithinPlugin, "Must set `productFileWithinPlugin`");
    Objects.requireNonNull(version, "Must set `version`");
    if (pluginPaths.isEmpty()) {
        throw new IllegalArgumentException("There should be at least one pluginPath");
    }// ww  w.  j  a va  2s.co m

    // create a PluginCatalog and validate the version policy / pluginPaths
    PluginCatalog catalog = new PluginCatalog(explicitVersionPolicy.getResult(), platforms, pluginPaths);

    // create a fake folder which will contain our sanitized product file
    File productPluginDir = project.file(this.productPluginDir);
    File tempProductDir = new File(destinationDir, productPluginDir.getName());

    // copy all images from original to the sanitized
    copyImages(productPluginDir, tempProductDir);

    // now create the sanitized product file
    File productFile = productPluginDir.toPath().resolve(productFileWithinPlugin).toFile();
    File tempProductFile = tempProductDir.toPath().resolve(productFileWithinPlugin).toFile();
    transformProductFile(productFile, tempProductFile, catalog, version);

    // finally setup the PdeBuildProperties to our temp product stuff
    props.setProp("topLevelElementType", "product");
    props.setProp("topLevelElementId", id);
    props.setProp("product", "/" + tempProductDir.getName() + "/" + productFileWithinPlugin);
}