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) 

Source Link

Document

Checks that the specified object reference is not null .

Usage

From source file:com.mcleodmoores.mvn.natives.PackageMojo.java

void setInputStreams(final InputStreamOpener inputStreams) {
    _inputStreams = Objects.requireNonNull(inputStreams);
}

From source file:net.maritimecloud.identityregistry.model.Vessel.java

/** Copies this vessel into the other */
public Vessel copyTo(Vessel vessel) {
    Objects.requireNonNull(vessel);
    vessel.setId(id);// ww w. j av  a2  s  .  c om
    vessel.setIdOrganization(idOrganization);
    vessel.setName(name);
    vessel.setVesselOrgId(vesselOrgId);
    vessel.setAttributes(attributes);
    vessel.setCertificate(certificates);
    return vessel;
}

From source file:org.trustedanalytics.resourceserver.data.InputStreamProvider.java

/**
 * Gets an InputStream for a path on HDFS.
 *
 * If given path is a directory, it will read files inside that dir and create
 * a SequenceInputStream from them, which emulates reading from directory just like from
 * a regular file. Notice that this method is not meant to read huge datasets
 * (as well as the whole project).//from w  w  w .  j a va2 s.  c o m
 * @param path
 * @return
 * @throws IOException
 */
public InputStream getInputStream(Path path) throws IOException {
    Objects.requireNonNull(path);
    if (fs.isFile(path)) {
        return fs.open(path);
    } else if (fs.isDirectory(path)) {
        FileStatus[] files = fs.listStatus(path);
        List<InputStream> paths = Arrays.stream(files).map(f -> {
            try {
                return fs.open(f.getPath());
            } catch (IOException e) {
                LOGGER.log(Level.SEVERE, "Cannot read file " + f.getPath().toString(), e);
                return null;
            }
        }).filter(f -> f != null).collect(Collectors.toList());
        return new SequenceInputStream(Collections.enumeration(paths));
    } else {
        throw new IllegalArgumentException("Given path " + path.toString() + " is neither file nor directory");
    }
}

From source file:org.eclipse.hono.service.amqp.AbstractAmqpEndpoint.java

/**
 * Sets configuration properties.//from  www .  j  a  v a2  s . c  o  m
 * 
 * @param props The properties.
 * @throws NullPointerException if props is {@code null}.
 */
@Qualifier(Constants.QUALIFIER_AMQP)
@Autowired(required = false)
public final void setConfiguration(final T props) {
    this.config = Objects.requireNonNull(props);
}

From source file:org.eclipse.hono.service.cache.SpringBasedExpiringValueCache.java

@Override
public void put(final K key, final V value, final Duration maxAge) {

    Objects.requireNonNull(key);
    Objects.requireNonNull(value);
    Objects.requireNonNull(maxAge);

    put(key, value, Instant.now().plus(maxAge));
}

From source file:org.eclipse.hono.service.credentials.CredentialsHttpEndpoint.java

/**
 * Creates an endpoint for a Vertx instance.
 *
 * @param vertx The Vertx instance to use.
 * @throws NullPointerException if vertx is {@code null};
 *///from   w w w. j av a  2  s  .c om
@Autowired
public CredentialsHttpEndpoint(final Vertx vertx) {
    super(Objects.requireNonNull(vertx));
}

From source file:com.smoketurner.dropwizard.consul.config.ConsulLookup.java

/**
 * Constructor/*from  w w w  . java2s .c om*/
 *
 * @param consul
 *            Consul client
 * @param strict
 *            {@code true} if looking up undefined environment variables
 *            should throw a {@link UndefinedEnvironmentVariableException},
 *            {@code false} otherwise.
 * @throws UndefinedEnvironmentVariableException
 *             if the environment variable doesn't exist and strict behavior
 *             is enabled.
 */
public ConsulLookup(@Nonnull final Consul consul, final boolean strict) {
    this.consul = Objects.requireNonNull(consul);
    this.strict = strict;
}

From source file:net.sf.jabref.exporter.ExportToClipboardAction.java

public ExportToClipboardAction(JabRefFrame frame) {
    this.frame = Objects.requireNonNull(frame);
}

From source file:org.fcrepo.camel.ldpath.FedoraProvider.java

/**
 * FedoraProvider/*  w  w w  .ja v a 2  s  . c o m*/
 * @param builder FcrepoHttpClientBuilder for building HttpClient
 */
public FedoraProvider(final FcrepoHttpClientBuilder builder) {
    Objects.requireNonNull(builder);
    httpClient = builder.build();
}

From source file:edu.umich.flowfence.service.NamespaceSharedPrefs.java

public static NamespaceSharedPrefs get(SharedPreferences basePrefs, String taintSetNamespace,
        String... taintNamespaces) {
    Objects.requireNonNull(taintSetNamespace);
    taintNamespaces = ArrayUtils.nullToEmpty(taintNamespaces);
    if (taintNamespaces.length == 0) {
        throw new IllegalArgumentException("Need at least one taint namespace!");
    }//from w ww  .  jav  a2s .  c om
    Set<String> taintNamespaceSet = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(taintNamespaces)));
    if (taintNamespaceSet.contains(taintSetNamespace)) {
        throw new IllegalArgumentException("Taint set namespace also a taint namespace");
    }
    synchronized (g_mPrefsLookup) {
        NamespaceSharedPrefs prefsStrong = null;
        WeakReference<NamespaceSharedPrefs> prefsWeak = g_mPrefsLookup.get(basePrefs);
        if (prefsWeak != null) {
            prefsStrong = prefsWeak.get();
        }
        if (prefsStrong != null) {
            if (!taintSetNamespace.equals(prefsStrong.mTaintSetNamespace)
                    || !taintNamespaceSet.equals(prefsStrong.mTaintNamespaces)) {
                Log.w(TAG,
                        String.format(
                                "Inconsistent initialization: "
                                        + "initialized with TS=%s T=%s, retrieved with TS=%s T=%s",
                                prefsStrong.mTaintSetNamespace, prefsStrong.mTaintNamespaces, taintSetNamespace,
                                taintNamespaceSet));
            }
        } else {
            prefsStrong = new NamespaceSharedPrefs(basePrefs, taintSetNamespace, taintNamespaceSet);
            prefsWeak = new WeakReference<>(prefsStrong);
            g_mPrefsLookup.put(basePrefs, prefsWeak);
        }
        return prefsStrong;
    }
}