List of usage examples for com.google.common.base Preconditions checkState
public static void checkState(boolean expression, @Nullable Object errorMessage)
From source file:com.proofpoint.galaxy.agent.MockDeploymentManager.java
@Override public Deployment install(Installation installation) { Preconditions.checkNotNull(installation, "installation is null"); Preconditions.checkState(deployment == null, "slot has an active deployment"); deployment = new Deployment(UUID.randomUUID(), location, new File("installation"), new File("data"), installation.getAssignment(), installation.getResources()); return deployment; }
From source file:com.spotify.apollo.test.response.SequenceResponseSource.java
@Override public ResponseWithDelay create(Request request) { Preconditions.checkState(responseWithDelayIterator.hasNext(), "No more responses specified!"); return responseWithDelayIterator.next(); }
From source file:org.apache.beam.sdk.extensions.euphoria.core.translate.OperatorTransform.java
public static <InputT, OutputT, OperatorT extends Operator<OutputT>> PCollection<OutputT> apply( OperatorT operator, PCollectionList<InputT> inputs) { final Optional<OperatorTranslator<InputT, OutputT, OperatorT>> maybeTranslator = TranslatorProvider .of(inputs.getPipeline()).findTranslator(operator); if (maybeTranslator.isPresent()) { final PCollection<OutputT> output = inputs.apply( operator.getName().orElseGet(() -> operator.getClass().getName()), new OperatorTransform<>(operator, maybeTranslator.orElse(null))); Preconditions.checkState(output.getTypeDescriptor() != null, "Translator should always return a typed PCollection."); return output; }//from w ww. j a v a2s.c o m throw new IllegalStateException("Unable to find translator for basic operator [" + operator.getClass() + "] with name [" + operator.getName().orElse(null) + "."); }
From source file:org.kitesdk.examples.spark.CorrelateEvents.java
@Override public int run(List<String> args) throws Exception { String inputUri = uri;// w w w .j a va2 s . com String outputUri = "dataset:hive?dataset=correlated_events"; if (args.size() == 1) { outputUri = args.get(0); } Preconditions.checkState(Datasets.exists(inputUri), "input dataset doesn't exists"); if (!Datasets.exists(outputUri)) { Datasets.create(outputUri, new DatasetDescriptor.Builder().format("avro").schema(CorrelatedEvents.class).build()); } CorrelateEventsTask task = new CorrelateEventsTask(inputUri, outputUri); task.run(); return 0; }
From source file:org.opendaylight.controller.cluster.datastore.ReadWriteShardDataTreeTransaction.java
ShardDataTreeCohort ready() { Preconditions.checkState(close(), "Transaction is already closed"); return parent.finishTransaction(this); }
From source file:codecrafter47.bungeetablistplus.api.sponge.BungeeTabListPlusSpongeAPI.java
/** * Unregisters all variables registered by the give plugin * * @param plugin the plugin//from w ww. ja va 2 s .co m */ public static void unregisterVariables(Object plugin) { Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); instance.unregisterVariables0(plugin); }
From source file:org.opendaylight.protocol.bgp.labeled.unicast.OriginatorSrgbTlvParser.java
private static List<SrgbValue> parseSrgbs(final ByteBuf buffer) { Preconditions.checkState(buffer.readableBytes() % SRGB_LENGTH == 0, "Number of SRGBs doesn't fit available bytes."); final List<SrgbValue> ret = new ArrayList<SrgbValue>(); while (buffer.isReadable()) { ret.add(new SrgbValueBuilder().setBase(new Srgb((long) buffer.readUnsignedMedium())) .setRange(new Srgb((long) buffer.readUnsignedMedium())).build()); }/*from ww w . ja va 2 s. c om*/ return ret; }
From source file:com.google.wave.splash.auth.oauth.OAuthSessionContext.java
@Override public String getSessionKey() { Preconditions.checkState(isAuthenticated(), "not authenticated"); // TODO: Use an id provided by the profile server instead. return String.valueOf(accessor.accessToken.hashCode()); }
From source file:org.n52.wps.algorithm.descriptor.InputDescriptor.java
protected InputDescriptor(Builder<? extends Builder<?, T>, T> builder) { super(builder); this.minOccurs = builder.minOccurs; this.maxOccurs = builder.maxOccurs; Preconditions.checkState(maxOccurs.longValue() >= minOccurs.longValue(), "maxOccurs must be >= minOccurs"); }
From source file:net.tenorite.protocol.ClassicStyleAddMessage.java
@Value.Check protected void check() { int lines = getLines(); Preconditions.checkState((lines == 1 || lines == 2 || lines == 4), "invalid value " + lines + " for 'lines', allowed values are 1, 2 or 4"); }