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:dk.dma.msiproxy.common.settings.Settings.java

/**
 * Returns the value associated with the setting.
 * If it does not exist, it is created/*from  w w w  . ja v a2s.  c om*/
 *
 * @param setting the source
 * @return the associated value
 */
public String get(Setting setting) {
    Objects.requireNonNull(setting, "Must specify valid setting");

    String result;

    // If a corresponding system property is set, it takes precedence
    result = System.getProperty(setting.getSettingName());

    // Check if it has been defined in the properties file
    if (result == null) {
        result = properties.getProperty(setting.getSettingName(), setting.defaultValue());
    }

    if (result != null && setting.substituteSystemProperties()) {
        for (Object key : System.getProperties().keySet()) {
            result = result.replaceAll("\\$\\{" + key + "\\}",
                    Matcher.quoteReplacement(System.getProperty("" + key)));
        }
    }

    return result;
}

From source file:alfio.model.result.Result.java

public <K> Result<K> flatMap(Function<T, Result<K>> mapper) {
    if (isSuccess()) {
        return Objects.requireNonNull(mapper.apply(data), "this method does not allow null values");
    }/*ww  w.j a v a2 s.c  o m*/
    return Result.error(this.errors);
}

From source file:com.github.horrorho.inflatabledonkey.chunk.engine.standard.StandardChunkEngine.java

public StandardChunkEngine(ChunkStore chunkStore) {
    this.chunkStore = Objects.requireNonNull(chunkStore, "chunkStore");
}

From source file:com.qwazr.compiler.JavaCompiler.java

static JavaCompiler newInstance(ExecutorService executorService, File javaSourceDirectory,
        File javaClassesDirectory, File... classPathDirectories) throws IOException, URISyntaxException {
    Objects.requireNonNull(javaSourceDirectory, "No source directory given (null)");
    Objects.requireNonNull(javaClassesDirectory, "No class directory given (null)");
    final FileSystem fs = FileSystems.getDefault();
    final List<URL> urlList = new ArrayList<URL>();
    urlList.add(javaClassesDirectory.toURI().toURL());
    final String classPath = buildClassPath(classPathDirectories, urlList);
    return new JavaCompiler(executorService, javaSourceDirectory, javaClassesDirectory, classPath, urlList);
}

From source file:com.fizzed.blaze.ssh.impl.JschSftpSession.java

public JschSftpSession(SshSession session, ChannelSftp channel) {
    Objects.requireNonNull(session, "session cannot be null");
    Objects.requireNonNull(channel, "channel cannot be null");
    this.session = session;
    this.channel = channel;
    // somewhat unorthodox but we want the current working directory
    this.pwd();/*from  w  w w.  j a v  a2s. c  o  m*/
}

From source file:com.stewel.dataflow.assocrules.AlgoAgrawalFaster94.java

public AlgoAgrawalFaster94(@Nonnull final ItemsetCandidateGenerator itemsetsCandidateGenerator,
        @Nonnull final ItemsetSupportCalculator itemsetSupportCalculator,
        @Nonnull final AssociationRuleWriter associationRuleWriter, @Nonnull final Itemsets patterns,
        final long databaseSize, final double minimumConfidence, final double minimumLift) {
    this.itemsetsCandidateGenerator = Objects.requireNonNull(itemsetsCandidateGenerator,
            "itemsetsCandidateGenerator");
    this.itemsetSupportCalculator = Objects.requireNonNull(itemsetSupportCalculator,
            "itemsetSupportCalculator");
    this.associationRuleWriter = Objects.requireNonNull(associationRuleWriter, "associationRuleWriter");
    this.patterns = Objects.requireNonNull(patterns, "patterns");
    this.databaseSize = databaseSize;
    this.minimumConfidence = minimumConfidence;
    this.minimumLift = minimumLift;
    itemsetSupportCalculator.init(patterns);
}

From source file:io.lavagna.web.security.SecurityConfiguration.java

List<UrlMatcher> buildMatcherList() {
    List<UrlMatcher> r = new ArrayList<>();

    if (!loginUrlDisabled) {
        Objects.requireNonNull(loginUrlMatcher, "login urls must be configured or disabled");
        Objects.requireNonNull(logoutUrlMatcher, "logout urls must be configured or disabled");
        Objects.requireNonNull(lockUrlMatcher, "lock urls must be configured or disabled");
        Objects.requireNonNull(lockPageUrlMatcher, "lock page urls must be configured or disabled");
        Objects.requireNonNull(sessionHandler, "sessionHandler must be defined or login url must be disabled");
        r.add(loginUrlMatcher);//ww w. j a  va  2s.c  om
        r.add(logoutUrlMatcher);

        r.add(lockUrlMatcher);
        r.add(lockPageUrlMatcher);
    }
    r.addAll(urlMatchers);
    return r;
}

From source file:eu.ggnet.dwoss.receipt.UiUnitSupport.java

public UiUnitSupport(UnitProcessor unitProcessor) {
    this.unitProcessor = Objects.requireNonNull(unitProcessor,
            UnitProcessor.class.getSimpleName() + " must not be null");
}

From source file:com.linkedin.pinot.queries.TestHelper.java

TestHelper(@Nonnull String tableName, @Nullable PropertiesConfiguration serverConf) throws IOException {
    this.tableName = Objects.requireNonNull(tableName, "Table name should not be null");
    if (serverConf != null) {
        this.serverConf = serverConf;
    } else {// w w  w  .  ja  v a 2s .c o m
        this.serverConf = new TestingServerPropertiesBuilder(tableName).build();
    }
    this.serverConf.setDelimiterParsingDisabled(false);

    serverMetrics = new ServerMetrics(new MetricsRegistry());
    TableDataManagerProvider.setServerMetrics(serverMetrics);
    instanceDataManager = FileBasedInstanceDataManager.getInstanceDataManager();
    queryExecutor = new ServerQueryExecutorV1Impl(false);
}

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

/**
 * Set the username from an {@link AbstractPropertyValue}.
 * //from  w ww  .  j  a va  2  s. co  m
 * @param username
 *          the username
 */
public void setUsername(AbstractPropertyValue username) {
    Objects.requireNonNull(username, "username must not be null");
    Assert.isInstanceOf(ScalarPropertyValue.class, username, "username must be a scalar value");
    this.username = ((ScalarPropertyValue) username).getValue();
}