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:edu.umd.umiacs.clip.tools.io.GZIPFiles.java

protected static Path write(Path path, Iterable<? extends CharSequence> lines, Charset cs,
        OpenOption... options) throws IOException {
    Objects.requireNonNull(lines);
    OutputStream out = newOutputStream(path, options);
    try (BufferedWriter writer = new BufferedWriter(
            new OutputStreamWriter(new GZIPOutputStream(out), UTF_8.newEncoder().onMalformedInput(IGNORE)),
            BUFFER_SIZE)) {//from   w  w  w . j a v  a2  s. c o m
        for (CharSequence line : lines) {
            writer.append(line);
            writer.newLine();
        }
    }
    return path;
}

From source file:io.lavagna.service.BoardColumnRepository.java

/**
 * Returns the new Column/*from  w ww  . j a  va  2  s.c  o  m*/
 * 
 * @param name
 * @param boardId
 * @return
 */
@Transactional(readOnly = false)
public BoardColumn addColumnToBoard(String name, int definitionId, BoardColumnLocation location, int boardId) {
    Objects.requireNonNull(name);
    Objects.requireNonNull(location);

    queries.addColumnToBoard(trimToNull(name), boardId, location.toString(), definitionId);

    return queries.findLastCreatedColumn();
}

From source file:com.ejisto.modules.vertx.handler.Boilerplate.java

private static void internalServeResource(HttpServerResponse response, Path resourcePath, String contentType) {
    try {//from  ww w.  jav  a2 s. c  o  m
        Objects.requireNonNull(resourcePath);
        final byte[] resourceBytes = Files.readAllBytes(resourcePath);
        Buffer b = new Buffer(resourceBytes);
        response.putHeader(HttpHeaders.CONTENT_TYPE, contentType)
                .putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(resourceBytes.length)).write(b).end();
    } catch (IOException e) {
        response.setStatusCode(HttpResponseStatus.NOT_FOUND.code());
        response.setStatusMessage(e.getMessage());
    }
}

From source file:org.eclipse.hono.connection.ConnectionFactoryImpl.java

@Override
public void connect(final ProtonClientOptions options,
        final Handler<AsyncResult<ProtonConnection>> closeHandler,
        final Handler<ProtonConnection> disconnectHandler,
        final Handler<AsyncResult<ProtonConnection>> connectionResultHandler) {

    if (vertx == null) {
        throw new IllegalStateException("Vert.x instance must be set");
    } else if (config == null) {
        throw new IllegalStateException("Client configuration must be set");
    }//from  w ww  .  ja  va  2s  . c  o m

    Objects.requireNonNull(connectionResultHandler);
    final ProtonClientOptions clientOptions = options != null ? options : new ProtonClientOptions();
    addOptions(clientOptions);

    ProtonClient client = ProtonClient.create(vertx);
    logger.info("connecting to AMQP 1.0 container [{}://{}:{}]", clientOptions.isSsl() ? "amqps" : "amqp",
            config.getHost(), config.getPort());
    client.connect(clientOptions, config.getHost(), config.getPort(), config.getUsername(),
            config.getPassword(), conAttempt -> handleConnectionAttemptResult(conAttempt, clientOptions,
                    closeHandler, disconnectHandler, connectionResultHandler));
}

From source file:net.sf.jabref.logic.util.Version.java

/**
 * @return true iff this version is newer than the passed one
 *///w  w  w. ja va  2  s.c o  m
public boolean isNewerThan(Version otherVersion) {
    Objects.requireNonNull(otherVersion);
    if (Objects.equals(this, otherVersion)) {
        return false;
    } else if (this.getFullVersion().equals(BuildInfo.UNKNOWN_VERSION)) {
        return false;
    } else if (otherVersion.getFullVersion().equals(BuildInfo.UNKNOWN_VERSION)) {
        return false;
    } else if (this.getMajor() > otherVersion.getMajor()) {
        return true;
    } else if (this.getMajor() == otherVersion.getMajor()) {
        if (this.getMinor() > otherVersion.getMinor()) {
            return true;
        } else {
            return (this.getMinor() == otherVersion.getMinor()) && (this.getPatch() > otherVersion.getPatch());
        }
    } else {
        return false;
    }
}

From source file:at.gridtec.lambda4j.function.bi.BiByteFunction.java

/**
 * Lifts a partial {@link BiByteFunction} into a total {@link BiByteFunction} that returns an {@link Optional}
 * result./* w  w  w  . java2s  .c o  m*/
 *
 * @param <R> The type of return value from the function
 * @param partial A function that is only defined for some values in its domain
 * @return A partial {@code BiByteFunction} lifted into a total {@code BiByteFunction} that returns an {@code
 * Optional} result.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> BiByteFunction<Optional<R>> lift(@Nonnull final BiByteFunction<? extends R> partial) {
    Objects.requireNonNull(partial);
    return (value1, value2) -> Optional.ofNullable(partial.apply(value1, value2));
}

From source file:at.gridtec.lambda4j.function.bi.BiCharFunction.java

/**
 * Lifts a partial {@link BiCharFunction} into a total {@link BiCharFunction} that returns an {@link Optional}
 * result.//  w  w w .j a  v a2 s. c  o  m
 *
 * @param <R> The type of return value from the function
 * @param partial A function that is only defined for some values in its domain
 * @return A partial {@code BiCharFunction} lifted into a total {@code BiCharFunction} that returns an {@code
 * Optional} result.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> BiCharFunction<Optional<R>> lift(@Nonnull final BiCharFunction<? extends R> partial) {
    Objects.requireNonNull(partial);
    return (value1, value2) -> Optional.ofNullable(partial.apply(value1, value2));
}

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

public void setContainer(Container c) {
    container = Objects.requireNonNull(c);
}

From source file:com.github.horrorho.inflatabledonkey.util.LZFSEExtInputStream.java

LZFSEExtInputStream(Process process, IOException error) {
    this.process = Objects.requireNonNull(process);
    this.is = new BufferedInputStream(process.getInputStream());
    this.error = error;
}

From source file:at.gridtec.lambda4j.function.bi.BiFloatFunction.java

/**
 * Lifts a partial {@link BiFloatFunction} into a total {@link BiFloatFunction} that returns an {@link Optional}
 * result.//from w  w  w.  java 2 s  .  co m
 *
 * @param <R> The type of return value from the function
 * @param partial A function that is only defined for some values in its domain
 * @return A partial {@code BiFloatFunction} lifted into a total {@code BiFloatFunction} that returns an {@code
 * Optional} result.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> BiFloatFunction<Optional<R>> lift(@Nonnull final BiFloatFunction<? extends R> partial) {
    Objects.requireNonNull(partial);
    return (value1, value2) -> Optional.ofNullable(partial.apply(value1, value2));
}