Example usage for com.google.common.base Preconditions checkNotNull

List of usage examples for com.google.common.base Preconditions checkNotNull

Introduction

In this page you can find the example usage for com.google.common.base Preconditions checkNotNull.

Prototype

public static <T> T checkNotNull(T reference, @Nullable String errorMessageTemplate,
        @Nullable Object... errorMessageArgs) 

Source Link

Document

Ensures that an object reference passed as a parameter to the calling method is not null.

Usage

From source file:org.bin01.db.verifier.Types.java

public static <A, B extends A> B checkType(A value, Class<B> target, String name) {
    Preconditions.checkNotNull(value, "%s is null", name);
    Preconditions.checkArgument(target.isInstance(value), "%s must be of type %s, not %s", name,
            target.getName(), value.getClass().getName());
    return target.cast(value);
}

From source file:org.locationtech.geogig.web.api.RESTUtils.java

public static RepositoryProvider repositoryProvider(Request request) {
    Object provider = request.getAttributes().get(RepositoryProvider.KEY);
    Preconditions.checkNotNull(provider, "No RepositoryProvider found in request attributes under the key %s",
            RepositoryProvider.KEY);/* www.  j  a  va 2 s.  com*/
    Preconditions.checkState(provider instanceof RepositoryProvider,
            "Request attribute %s is not of type RepositoryProvider: %s", RepositoryProvider.KEY,
            provider.getClass());
    return (RepositoryProvider) provider;
}