List of usage examples for com.google.common.base Preconditions checkState
public static void checkState(boolean expression, @Nullable Object errorMessage)
From source file:com.b2international.snowowl.snomed.datastore.taxonomy.Taxonomy.java
public Taxonomy(ISnomedTaxonomyBuilder newTaxonomy, ISnomedTaxonomyBuilder oldTaxonomy, SnomedTaxonomyStatus status, LongSet newEdges, LongSet changedEdges, LongSet detachedEdges) { this.newTaxonomy = newTaxonomy; Preconditions.checkState(!newTaxonomy.isDirty(), "Builder for representing the new state of the taxonomy has dirty state."); this.oldTaxonomy = oldTaxonomy; this.status = status; this.newEdges = newEdges; this.changedEdges = changedEdges; this.detachedEdges = detachedEdges; }
From source file:org.janusgraph.diskstorage.util.time.Timer.java
public Timer start() { Preconditions.checkState(null == start, "Timer can only be started once"); start = times.getTime(); return this; }
From source file:org.ros.concurrent.CancellableLoop.java
@Override public void run() { synchronized (mutex) { Preconditions.checkState(!ranOnce, "CancellableLoops cannot be restarted."); ranOnce = true;/* ww w . j av a 2 s . c o m*/ thread = Thread.currentThread(); } try { setup(); while (!thread.isInterrupted()) { loop(); } } catch (InterruptedException e) { handleInterruptedException(e); } finally { thread = null; cleanup(); } }
From source file:net.myrrix.online.MultiRescorer.java
/** * @param rescorers {@link IDRescorer} objects to delegate to *//*from w w w. j av a 2 s. co m*/ public MultiRescorer(List<IDRescorer> rescorers) { Preconditions.checkNotNull(rescorers); Preconditions.checkState(!rescorers.isEmpty(), "rescorers is empty"); this.rescorers = rescorers.toArray(new IDRescorer[rescorers.size()]); }
From source file:org.sonar.javascript.cfg.JsCfgForwardingBlock.java
@Override public ImmutableSet<CfgBlock> successors() { Preconditions.checkState(successor != null, "No successor was set on " + this); return ImmutableSet.<CfgBlock>of(successor); }
From source file:com.cloudera.crash.carriers.Carrier.java
@SuppressWarnings("unchecked") public final void emit(Object key, Object value) { Preconditions.checkState(emitter != null, "Cannot call emit outside of processing"); emit((T) Pair.of(key, value));/*from w w w .j a v a 2 s.co m*/ }
From source file:com.dangdang.ddframe.rdb.sharding.api.rule.DataSourceRule.java
public DataSourceRule(final Map<String, DataSource> dataSourceMap, final String defaultDataSourceName) { Preconditions.checkState(!dataSourceMap.isEmpty(), "Must have one data source at least."); this.dataSourceMap = dataSourceMap; if (1 == dataSourceMap.size()) { this.defaultDataSourceName = dataSourceMap.entrySet().iterator().next().getKey(); return;//from w ww. java2 s.co m } if (Strings.isNullOrEmpty(defaultDataSourceName)) { this.defaultDataSourceName = null; return; } Preconditions.checkState(dataSourceMap.containsKey(defaultDataSourceName), "Data source rule must include default data source."); this.defaultDataSourceName = defaultDataSourceName; }
From source file:com.google.devtools.build.lib.exec.LocalActionLogging.java
void finish() { Preconditions.checkState(isRunning, action); isRunning = false;/* ww w . j a v a 2 s .c o m*/ LOG.info("Finished running " + action.prettyPrint() + " in " + TimeUnit.NANOSECONDS.toMillis(BlazeClock.nanoTime() - startTime) + "ms"); }
From source file:com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceIdentifier.java
/** Returns a {@link BinaryResourceIdentifier} with the given identifiers. */ public static BinaryResourceIdentifier create(int packageId, int typeId, int entryId) { Preconditions.checkState((packageId & 0xFF) == packageId, "packageId must be <= 0xFF."); Preconditions.checkState((typeId & 0xFF) == typeId, "typeId must be <= 0xFF."); Preconditions.checkState((entryId & 0xFFFF) == entryId, "entryId must be <= 0xFFFF."); return new BinaryResourceIdentifier(packageId, typeId, entryId); }
From source file:org.opendaylight.netconf.sal.streams.websockets.WebSocketServer.java
/** * Destroy the existing instance/*from w w w. j av a 2 s . c o m*/ */ public static void destroyInstance() { Preconditions.checkState(instance != null, "createInstance() must be called prior to destroyInstance()"); instance.stop(); instance = null; }