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:io.github.retz.protocol.ScheduleRequest.java

@JsonCreator
public ScheduleRequest(@JsonProperty(value = "job", required = true) Job job) {
    this.job = Objects.requireNonNull(job);
}

From source file:onl.area51.httpd.action.Action.java

default Action andThen(Action after) {
    Objects.requireNonNull(after);
    return (req) -> {
        apply(req);/* www  .  jav  a 2  s . c om*/
        if (isOk(req)) {
            after.apply(req);
        }
    };
}

From source file:org.eclipse.hono.server.HonoSaslAuthenticatorFactory.java

/**
 * Creates a new factory for a Vertx environment.
 * /*from   w  w  w .  j  a  va 2s . c  o m*/
 * @param vertx the Vertx environment to run the factory in.
 */
public HonoSaslAuthenticatorFactory(@Autowired final Vertx vertx) {
    this.vertx = Objects.requireNonNull(vertx);
}

From source file:io.github.retz.protocol.data.DockerContainer.java

@JsonCreator
public DockerContainer(@JsonProperty(value = "image", required = true) String image,
        @JsonProperty("volumes") List<DockerVolume> volumes) {
    this.image = Objects.requireNonNull(image);
    this.volumes = (volumes == null) ? Arrays.asList() : volumes;
}

From source file:Main.java

/**
 * Concatenates multiple iterables into a single iterable. The iterator exposed by the returned
 * iterable does not support {@link Iterator#remove()} even if the input iterables do.
 *
 * @throws NullPointerException if {@code iterables} or any of its elements are {@code null}
 *//*from ww w.  j av a  2  s . co  m*/
public static <T> Iterable<T> concat(List<Iterable<T>> iterables) {
    for (Iterable<T> iterable : iterables) {
        Objects.requireNonNull(iterable);
    }
    return new Iterable<T>() {
        @Override
        public Iterator<T> iterator() {
            if (iterables.size() == 0) {
                return Collections.emptyIterator();
            }
            return new Iterator<T>() {
                Iterator<Iterable<T>> cursor = iterables.iterator();
                Iterator<T> currentIterator = cursor.next().iterator();

                private void advance() {
                    while (!currentIterator.hasNext() && cursor.hasNext()) {
                        currentIterator = cursor.next().iterator();
                    }
                }

                @Override
                public boolean hasNext() {
                    advance();
                    return currentIterator.hasNext();
                }

                @Override
                public T next() {
                    advance();
                    return currentIterator.next();
                }
            };
        }

    };
}

From source file:com.spotify.hamcrest.jackson.AbstractJsonNodeMatcher.java

AbstractJsonNodeMatcher(final JsonNodeType type) {
    super(JsonNode.class);
    this.type = Objects.requireNonNull(type);
}

From source file:io.servicecomb.serviceregistry.version.Version.java

public Version(String version) {
    Objects.requireNonNull(version);

    String[] versions = version.split("\\.", -1);
    if (versions.length > 3) {
        throw new IllegalStateException(String.format("Invalid version \"%s\".", version));
    }//ww w . java  2  s.c  o m

    if (versions.length < 3) {
        versions = (String[]) ArrayUtils.addAll(versions, ZERO);
    }
    this.major = parseNumber("major", version, versions[0]);
    this.minor = parseNumber("minor", version, versions[1]);
    this.patch = parseNumber("patch", version, versions[2]);

    this.version = combineStringVersion();
    this.numberVersion = combineVersion();
}

From source file:com.avanza.ymer.MongoDocumentCollection.java

public MongoDocumentCollection(DBCollection dbCollection) {
    this.dbCollection = Objects.requireNonNull(dbCollection);
}

From source file:cn.edu.zjnu.acm.judge.service.JudgeServerService.java

public void delete(Path path) {
    if (!judgeConfiguration.isDeleteTempFile()) {
        return;//from w ww  . ja v a2s.c  o m
    }
    try {
        DeleteHelper.delete(Objects.requireNonNull(path));
    } catch (IOException ignore) {
        // delete again
        try {
            DeleteHelper.delete(path);
        } catch (IOException ignore2) {
        }
    }
}

From source file:com.yevster.spdxtra.Validate.java

public static void noNulls(Object... array) {
    for (Object o : array) {
        Objects.requireNonNull(o);
    }
}