List of usage examples for com.google.common.base Preconditions checkState
public static void checkState(boolean expression, @Nullable Object errorMessage)
From source file:org.eclipse.viatra.transformation.evm.api.adapter.AdaptableConflictResolver.java
public AdaptableConflictResolver(ConflictResolver delegatedConflictResolver, AdaptableEVM container) { this.delegatedConflictResolver = delegatedConflictResolver; Preconditions.checkState(this.delegatedConflictResolver != null, "Delegated Conflict resolver must be set."); this.container = container; }
From source file:com.google.javascript.jscomp.fuzzing.ExistingIdentifierFuzzer.java
@Override protected Node generate(int budget, Set<Type> types) { Preconditions.checkState(isEnough(1), "No symbol defined."); int flags = 0; if (excludeExterns) { flags = ScopeManager.EXCLUDE_EXTERNS; }//from w w w .ja va 2 s . co m return Node.newString(Token.NAME, context.scopeManager.getRandomSymbol(type, flags).name); }
From source file:com.google.jstestdriver.requesthandlers.RequestScope.java
/** * Enter the {@link RequestScope}./*w ww . j a v a 2s .c om*/ */ public void enter() { Preconditions.checkState(values.get() == null, "Scope already entered."); values.set(Maps.<Key<?>, Object>newHashMap()); }
From source file:com.google.devtools.build.android.desugar.CloseResourceMethodScanner.java
@Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {//from ww w .jav a 2s . c om Preconditions.checkState(internalName == null, "This scanner has been used."); this.internalName = name; this.classFileVersion = version; super.visit(version, access, name, signature, superName, interfaces); }
From source file:to.lean.tools.gmail.importer.fixers.CorruptEmailFixer.java
private boolean hasValidFrom(JavaxMailMessage message) { String[] fromHeaders = message.getHeader("From"); Preconditions.checkState(fromHeaders.length == 1, "Expected exactly 1 From header, got: " + Arrays.toString(fromHeaders)); String rawAddress = fromHeaders[0].replaceAll("\\s+", " "); try {//from ww w . j a v a 2 s .c o m InternetAddress[] address = InternetAddress.parseHeader(rawAddress, true); Preconditions.checkState(address.length == 1, "Expected exactly 1 From address, got: " + Arrays.toString(address)); System.err.format("Valid? %s == %s\n", address[0].toString(), rawAddress); return address[0].toString().equals(rawAddress); } catch (AddressException e) { System.err.format("Not valid from because: %s", e.getMessage()); return false; } }
From source file:org.locationtech.geogig.api.plumbing.DescribeFeatureType.java
/** * Retrieves the set of property descriptors for the given feature type. * /* ww w . ja va2 s. com*/ * @return a sorted set of all the property descriptors of the feature type. */ @Override protected ImmutableSet<PropertyDescriptor> _call() { Preconditions.checkState(featureType != null, "FeatureType has not been set."); FeatureType type = featureType.type(); ImmutableSet.Builder<PropertyDescriptor> propertySetBuilder = new ImmutableSet.Builder<PropertyDescriptor>(); propertySetBuilder.addAll(type.getDescriptors()); return propertySetBuilder.build(); }
From source file:com.mapr.synth.samplers.MapSampler.java
@Override public JsonNode sample() { Preconditions.checkState(base != null, "Need to specify definition"); return base.sample(); }
From source file:org.sonar.api.batch.sensor.measure.internal.DefaultMeasureBuilder.java
@Override public DefaultMeasureBuilder<G> onFile(InputFile inputFile) { Preconditions.checkState(!this.onProject, "onProject already called"); Preconditions.checkState(this.file == null, "onFile already called"); Preconditions.checkNotNull(inputFile, "InputFile should be non null"); this.file = inputFile; return this; }
From source file:org.apache.usergrid.chop.api.store.amazon.InstanceValues.java
public InstanceValues(Instance instance, String sshKeyFile) { Preconditions.checkNotNull(sshKeyFile, "The 'sshKeyFile' parameter cannot be null."); Preconditions.checkNotNull(instance, "The 'instance parameter cannot be null."); Preconditions.checkState( instance.getPublicIpAddress() != null && (!instance.getPublicIpAddress().isEmpty()), "Public IP address field of the 'instance' parameter cannot be empty"); this.sshKeyFile = sshKeyFile; this.instance = instance; }
From source file:com.torodb.core.cursors.IteratorCursor.java
@Override public E next() { Preconditions.checkState(!closed, "The cursor is closed"); return iterator.next(); }