List of usage examples for com.google.common.base Preconditions checkState
public static void checkState(boolean expression, @Nullable Object errorMessage)
From source file:org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult.java
void setResult(final NormalizedNode<?, ?> result) { Preconditions.checkState(!this.finished, "Result was already set."); this.finished = true; this.result = result; }
From source file:com.facebook.buck.rules.coercer.Either.java
private Either(@Nullable LEFT left, @Nullable RIGHT right) { Preconditions.checkState(left != null ^ right != null, "Exactly one of left or right must be set"); this.left = left; this.right = right; }
From source file:org.eclipse.xtend.core.macro.declaration.JvmElementImpl.java
public void remove() { this.checkMutable(); Resource _eResource = this.getDelegate().eResource(); boolean _tripleNotEquals = (_eResource != null); StringConcatenation _builder = new StringConcatenation(); _builder.append("This element has already been removed: "); T _delegate = this.getDelegate(); _builder.append(_delegate);/*from w w w .j a va2 s . c om*/ Preconditions.checkState(_tripleNotEquals, _builder); this.getCompilationUnit().getJvmModelAssociator().removeAllAssociation(this.getDelegate()); EcoreUtil.remove(this.getDelegate()); Resource _eResource_1 = this.getDelegate().eResource(); boolean _tripleEquals = (_eResource_1 == null); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("Couldn\'t remove: "); T _delegate_1 = this.getDelegate(); _builder_1.append(_delegate_1); Preconditions.checkState(_tripleEquals, _builder_1); }
From source file:com.google.devtools.build.lib.rules.android.MergedAndroidResources.java
public static MergedAndroidResources mergeFrom(AndroidDataContext dataContext, ParsedAndroidResources parsed, ResourceDependencies resourceDeps, boolean enableDataBinding, AndroidAaptVersion aaptVersion) throws InterruptedException { AndroidConfiguration androidConfiguration = dataContext.getAndroidConfig(); boolean useCompiledMerge = aaptVersion == AndroidAaptVersion.AAPT2 && androidConfiguration.skipParsingAction(); Preconditions.checkState(!useCompiledMerge || parsed.getCompiledSymbols() != null, "Should not use compiled merge if no compiled symbols are available!"); AndroidResourceMergingActionBuilder builder = new AndroidResourceMergingActionBuilder() .setJavaPackage(parsed.getJavaPackage()).withDependencies(resourceDeps) .setThrowOnResourceConflict(androidConfiguration.throwOnResourceConflict()) .setUseCompiledMerge(useCompiledMerge); if (enableDataBinding) { builder.setDataBindingInfoZip(/*from ww w. ja v a2s.co m*/ DataBinding.getLayoutInfoFile(dataContext.getActionConstructionContext())); } return builder .setManifestOut(dataContext.createOutputArtifact(AndroidRuleClasses.ANDROID_PROCESSED_MANIFEST)) .setMergedResourcesOut(dataContext.createOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_ZIP)) .setClassJarOut(dataContext.createOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_CLASS_JAR)) .build(dataContext, parsed); }
From source file:org.terasology.engine.TerasologyEngineBuilder.java
public TerasologyEngine build() { Preconditions.checkState(timeSubsystem != null, "TimeSubsystem is required"); return new TerasologyEngine(timeSubsystem, otherSubsystems); }
From source file:org.xacml4j.spring.FunctionProvider.java
public void setProviderInstance(Object instance) { Preconditions.checkState(providerClass == null, "Either provider instance or class must be specified but not both"); this.providerInstance = instance; }
From source file:com.torodb.core.cursors.IteratorCursor.java
@Override public boolean hasNext() { Preconditions.checkState(!closed, "The cursor is closed"); return iterator.hasNext(); }
From source file:alluxio.wire.MetricValue.java
/** * Creates a new instance of {@link MetricValue} from a thrift representation. * * @param metricValue the thrift representation of a metric value *///from www.j ava2 s. c o m private MetricValue(alluxio.thrift.MetricValue metricValue) { Preconditions.checkState(metricValue.isSetDoubleValue() || metricValue.isSetLongValue(), "only one of longValue and doubleValue can be set"); if (metricValue.isSetDoubleValue()) { mDoubleValue = metricValue.getDoubleValue(); } else if (metricValue.isSetLongValue()) { mLongValue = metricValue.getLongValue(); } }
From source file:model.utilities.stats.collectors.DataStorage.java
protected DataStorage(Class<T> enumType) { data = new EnumMap<>(enumType); this.enumType = enumType; Preconditions.checkState(enumType.getEnumConstants().length > 0, "the enum must have a size!"); for (T type : enumType.getEnumConstants()) data.put(type, new DailyObservations()); }
From source file:works.chatterbox.hooks.ircchannels.channels.modes.AnnotationMode.java
private <F> F withModeInfo(@NotNull final Function<ModeInfo, F> function) { Preconditions.checkNotNull(function, "function was null"); final ModeInfo modeInfo = this.getModeInfo(); Preconditions.checkState(modeInfo != null, "No ModeInfo"); return function.apply(modeInfo); }