List of usage examples for com.google.common.base Preconditions checkState
public static void checkState(boolean expression)
From source file:com.google.dart.compiler.backend.js.ClosureJsCodingConvention.java
/** * {@inheritDoc}/*from w w w . jav a 2 s. c o m*/ * * <p>Understands several different inheritance patterns that occur in * DartC generated code. */ @Override public SubclassRelationship getClassesDefinedByCall(Node callNode) { Node callName = callNode.getFirstChild(); SubclassType type = typeofClassDefiningName(callName); if (type != null && callNode.getChildCount() == 3) { // Only one type of call is expected. // $inherits(SubClass, SuperClass) Preconditions.checkState(type == SubclassType.INHERITS); Node subclass = callName.getNext(); Node superclass = callNode.getLastChild(); // bail out if either of the side of the "inherits" // isn't a real class name. This prevents us from // doing something weird in cases like: // goog.inherits(MySubClass, cond ? SuperClass1 : BaseClass2) if (subclass != null && subclass.isUnscopedQualifiedName() && superclass.isUnscopedQualifiedName()) { return new SubclassRelationship(type, subclass, superclass); } } return super.getClassesDefinedByCall(callNode); }
From source file:com.google.devtools.build.lib.profiler.memory.CurrentRuleTracker.java
public static RuleClass getRule() { Preconditions.checkState(enabled); return currentRule.get(); }
From source file:com.cloudera.impala.authorization.AuthorizeableTable.java
public AuthorizeableTable(String dbName, String tableName) { Preconditions.checkState(tableName != null && !tableName.isEmpty()); Preconditions.checkState(dbName != null && !dbName.isEmpty()); table_ = new org.apache.sentry.core.Table(tableName); database_ = new org.apache.sentry.core.Database(dbName); }
From source file:com.facebook.buck.rules.keys.AbstractDependencyFileEntry.java
@Value.Check protected void check() { Preconditions.checkState(!pathToFile().isAbsolute()); Preconditions.checkState(!pathWithinArchive().isPresent() || !pathWithinArchive().get().isAbsolute()); }
From source file:net.myrrix.online.MultiLongPairRescorer.java
public MultiLongPairRescorer(Rescorer<LongPair>... rescorers) { Preconditions.checkNotNull(rescorers); Preconditions.checkState(rescorers.length > 0); this.rescorers = rescorers; }
From source file:org.midonet.midolman.state.zkManagers.ConfigWithProperties.java
@JsonIgnore public <K, V> void setProperty(K key, V val) { key = Preconditions.checkNotNull(key); val = Preconditions.checkNotNull(val); Preconditions.checkState(properties != null); properties.put(key.toString(), val.toString()); }
From source file:com.google.javascript.jscomp.newtypes.NamespaceLit.java
@Override protected JSType computeJSType() { Preconditions.checkState(this.namespaceType == null); return JSType.fromObjectType(ObjectType.makeObjectType(this.commonTypes, this.window == null ? this.commonTypes.getLiteralObjNominalType() : this.window, null, null, this, false, ObjectKind.UNRESTRICTED)); }
From source file:org.b1.pack.standard.volume.StandardVolumeService.java
@Override public VolumeAllocator createVolumeAllocator(VolumeAllocatorProvider provider) { String volumeName = provider.getVolumeName(); long volumeCount = provider.getVolumeCount(); Matcher matcher = ALLOCATOR_PATTERN.matcher(volumeName); Preconditions.checkState(matcher.matches()); String baseName = matcher.group(1); String extension = Objects.firstNonNull(matcher.group(2), ".b1"); return volumeCount == 0 ? new StandardBasicVolumeAllocator(baseName + extension) : new StandardMultipartVolumeAllocator(baseName, volumeCount, extension); }
From source file:org.excalibur.core.util.MD5.java
public String hash(String message) { Preconditions.checkState(!Strings.isNullOrEmpty(message)); synchronized (this.messageDigest) { this.messageDigest.reset(); this.messageDigest.update(message.getBytes()); return new String(this.messageDigest.digest()); }// w w w .j a v a2s . co m }
From source file:org.kiji.schema.util.JvmId.java
/** * Returns the Unix process ID of this JVM. * * @return the Unix process ID of this JVM. *//*from w ww .j a v a 2s . c o m*/ public static int getPid() { try { final Process process = new ProcessBuilder("/bin/sh", "-c", "echo $PPID").start(); try { Preconditions.checkState(process.waitFor() == 0); } catch (InterruptedException ie) { throw new RuntimeInterruptedException(ie); } final String pidStr = IOUtils.toString(process.getInputStream()).trim(); return Integer.parseInt(pidStr); } catch (IOException ioe) { throw new KijiIOException(ioe); } }