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.facebook.util.Validator.java

public void checkState(boolean expression) throws T {
    try {//  ww  w . ja v a 2  s . c o  m
        Preconditions.checkState(expression);
    } catch (Exception e) {
        throw ExceptionUtils.wrap(e, clazz);
    }
}

From source file:com.dangdang.ddframe.job.cloud.context.TaskContext.java

/**
 * ??.//  w w  w  . java2s  .  c o m
 *
 * @param id 
 * @return 
 */
public static TaskContext from(final String id) {
    String[] result = id.split(DELIMITER);
    Preconditions.checkState(5 == result.length);
    return new TaskContext(id, new MetaInfo(result[0], Integer.parseInt(result[1])),
            ExecutionType.valueOf(result[2]), result[3]);
}

From source file:org.haiku.haikudepotserver.multipage.model.Pagination.java

/**
 * @param total is the total number of items in the entire result set
 * @param offset if the offset from 0 into the total number of items
 * @param max is the maximum number of items to show on a page
 *//*from  www .j av  a2s . co m*/

public Pagination(int total, int offset, int max) {
    Preconditions.checkState(offset >= 0);
    Preconditions.checkState(total >= 0);
    Preconditions.checkState(offset < total);
    Preconditions.checkState(max >= 1);
    this.offset = offset;
    this.total = total;
    this.max = max;
}

From source file:com.heartbleed.tls.records.HandshakeRecord.java

protected HandshakeRecord(byte[] recordBytes) {
    super(recordBytes);
    Preconditions.checkState(getContentType() == ContentType.HANDSHAKE);
}

From source file:graph.features.cpp.Bound.java

public Bound(final double lowerBound, final double upperBound) {
    Preconditions.checkState(Double.compare(lowerBound, upperBound) < 1);
    this.lowerBound = lowerBound;
    this.upperBound = upperBound;
}

From source file:com.heartbleed.tls.records.HeartbeatResponseMessage.java

protected HeartbeatResponseMessage(byte[] recordBytes) {
    super(recordBytes);
    Preconditions.checkState(getContentType() == ContentType.HEARTBEAT);
}

From source file:com.cloudera.impala.authorization.AuthorizeableFn.java

public AuthorizeableFn(String fnName) {
    Preconditions.checkState(fnName != null && !fnName.isEmpty());
    fnName_ = fnName;
}

From source file:org.haiku.pkg.model.PkgUrl.java

public PkgUrl(String input, PkgUrlType urlType) {
    super();//  w  w  w  . j a  v a2  s. c  o m
    Preconditions.checkNotNull(urlType);
    Preconditions.checkState(!Strings.isNullOrEmpty(input));

    input = input.trim();

    if (Strings.isNullOrEmpty(input)) {
        throw new IllegalStateException(
                "the input must be supplied and should not be an empty string when trimmed.");
    }

    Matcher matcher = PATTERN_NAMEANDURL.matcher(input);

    if (matcher.matches()) {
        this.url = matcher.group(3);
        this.name = Strings.emptyToNull(matcher.group(1).trim());
    } else {
        this.url = input;
    }

    this.urlType = urlType;
}

From source file:com.github.javarch.jsf.mbeans.AbstractDeleteManagedBean.java

@Override
public void onAction(T entidade) {
    Preconditions.checkState(entidade.getId() != null);
    repository.delete(entidade);
}

From source file:org.haiku.pkg.HpkStringTable.java

HpkStringTable(HpkHeapReader heapReader, long heapOffset, long heapLength, long expectedCount) {

    super();/*from w ww.j a v  a2  s  . c  o  m*/

    Preconditions.checkNotNull(heapReader);
    Preconditions.checkState(heapOffset >= 0 && heapOffset < Integer.MAX_VALUE);
    Preconditions.checkState(heapLength >= 0 && heapLength < Integer.MAX_VALUE);
    Preconditions.checkState(expectedCount >= 0 && expectedCount < Integer.MAX_VALUE);

    this.heapReader = heapReader;
    this.expectedCount = expectedCount;
    this.heapOffset = heapOffset;
    this.heapLength = heapLength;

}