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

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

Introduction

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

Prototype

public static void checkState(boolean expression) 

Source Link

Document

Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.

Usage

From source file:com.google.javascript.jscomp.newtypes.FunctionNamespace.java

@Override
protected JSType computeJSType() {
    Preconditions.checkState(this.namespaceType == null);
    return JSType.fromObjectType(ObjectType.makeObjectType(this.commonTypes, this.commonTypes.getFunctionType(),
            null, this.scope.getDeclaredFunctionType().toFunctionType(), this, false, ObjectKind.UNRESTRICTED));
}

From source file:org.apache.impala.authorization.AuthorizeableDb.java

public AuthorizeableDb(String dbName) {
    Preconditions.checkState(dbName != null && !dbName.isEmpty());
    database_ = new org.apache.sentry.core.model.db.Database(dbName);
}

From source file:org.ros.internal.node.response.ProtocolDescriptionResultFactory.java

@Override
public ProtocolDescription newFromValue(Object value) {
    List<Object> protocolParameters = Arrays.asList((Object[]) value);
    Preconditions.checkState(protocolParameters.size() == 3);
    Preconditions.checkState(protocolParameters.get(0).equals(ProtocolNames.TCPROS));
    AdvertiseAddress address = new AdvertiseAddress((String) protocolParameters.get(1));
    address.setStaticPort((Integer) protocolParameters.get(2));
    return new TcpRosProtocolDescription(address);
}

From source file:com.cloudera.oryx.als.common.rescorer.MultiLongPairRescorer.java

public MultiLongPairRescorer(List<PairRescorer> rescorers) {
    Preconditions.checkNotNull(rescorers);
    Preconditions.checkState(!rescorers.isEmpty());
    PairRescorer[] newArray = new PairRescorer[rescorers.size()];
    this.rescorers = rescorers.toArray(newArray);
}

From source file:com.programmablefun.Version.java

public Version(String version) {
    String parts[] = version.split("\\.");
    Preconditions.checkState(parts.length == 3);
    this.major = Integer.parseInt(parts[0]);
    this.minor = Integer.parseInt(parts[1]);
    this.patch = Integer.parseInt(parts[2]);
}

From source file:io.divolte.server.filesinks.gcs.DynamicDelegatingOutputStream.java

public void detachDelegate() throws IOException {
    Preconditions.checkState(wrapped != null);
    wrapped.flush();
    wrapped = null;
}

From source file:com.palantir.atlasdb.keyvalue.partition.util.CycleMap.java

public K nextKey(K key) {
    Preconditions.checkState(size() > 0);
    K next = higherKey(key);
    if (next == null) {
        next = firstKey();
    }
    return next;
}

From source file:com.facebook.buck.util.cache.JarContentHasher.java

public JarContentHasher(ProjectFilesystem filesystem, Path jarRelativePath) {
    Preconditions.checkState(!jarRelativePath.isAbsolute());
    this.filesystem = filesystem;
    this.jarRelativePath = jarRelativePath;
}

From source file:com.google.javascript.jscomp.fuzzing.Scope.java

String randomLabelForBreak(Random random) {
    Preconditions.checkState(loopLabels.size() + otherLabels.size() > 0);
    int rand = random.nextInt(loopLabels.size() + otherLabels.size());
    if (rand < loopLabels.size()) {
        return loopLabels.get(rand);
    } else {/*from   w  w w  .j av a 2s .c om*/
        return otherLabels.get(rand - loopLabels.size());
    }
}

From source file:com.google.gapid.rpc.SingleInFlight.java

public Context start() {
    Context result = new Context() {
        private ListenableFuture<?> future = null;
        private boolean cancelled = false;

        @Override/*from   www.  ja  v a  2  s. com*/
        public synchronized <T> void listen(ListenableFuture<T> f, Rpc.Callback<T> callback) {
            Preconditions.checkState(future == null);
            if (cancelled) {
                future.cancel(true);
            }
            future = f;
            Rpc.listen(f, callback);
        }

        @Override
        public synchronized void cancel() {
            cancelled = true;
            if (future != null) {
                future.cancel(true);
            }
        }
    };
    Context previous = active.getAndSet(result);
    if (previous != null) {
        previous.cancel();
    }
    return result;
}