List of usage examples for com.google.common.base Preconditions checkState
public static void checkState(boolean expression, @Nullable Object errorMessage)
From source file:lemon.elastic.query4j.esproxy.core.facet.AbstractFacetRequest.java
public AbstractFacetRequest(String name) { Preconditions.checkState(SpringStringUtils.hasText(name), "Facet can't be null or empty !!!"); this.name = name; }
From source file:org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.SimpleAttributeReadingStrategy.java
@Override AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException { XmlElement xmlElement = configNodes.get(0); Preconditions.checkState(configNodes.size() == 1, "This element should be present only once " + xmlElement + " but was " + configNodes.size()); String textContent = readElementContent(xmlElement); return AttributeConfigElement.create(postprocessNullableDefault(getNullableDefault()), postprocessParsedValue(textContent)); }
From source file:org.opendaylight.protocol.bgp.parser.spi.pojo.AbstractFamilyRegistry.java
protected synchronized AutoCloseable registerFamily(final Class<? extends C> clazz, final N number) { Preconditions.checkNotNull(clazz);//from ww w . j a v a 2s . c o m final Class<?> c = numberToClass.get(number); Preconditions.checkState(c == null, "Number " + number + " already registered to " + c); final N n = classToNumber.get(clazz); Preconditions.checkState(n == null, "Class " + clazz + " already registered to " + n); numberToClass.put(number, clazz); classToNumber.put(clazz, number); final Object lock = this; return new AbstractRegistration() { @Override protected void removeRegistration() { synchronized (lock) { classToNumber.remove(clazz); numberToClass.remove(number); } } }; }
From source file:io.macgyver.plugin.artifactory.AQLSearchBuilder.java
public JsonNode execute() { Preconditions.checkState(target != null, "OkRestTarget not set"); return target.path("api/search/aql").addHeader("Content-type", "text/plain").post(aql) .execute(JsonNode.class); }
From source file:org.opendaylight.controller.cluster.datastore.ClusterWrapperImpl.java
public ClusterWrapperImpl(ActorSystem actorSystem) { Preconditions.checkNotNull(actorSystem, "actorSystem should not be null"); cluster = Cluster.get(actorSystem);/*w w w . j a va2s .c om*/ Preconditions.checkState(cluster.getSelfRoles().size() > 0, "No akka roles were specified\n" + "One way to specify the member name is to pass a property on the command line like so\n" + " -Dakka.cluster.roles.0=member-3\n" + "member-3 here would be the name of the member"); currentMemberName = MemberName.forName(cluster.getSelfRoles().iterator().next()); selfAddress = cluster.selfAddress(); }
From source file:org.haiku.haikudepotserver.api1.AbstractApiImpl.java
protected Architecture getArchitecture(ObjectContext context, String architectureCode) throws ObjectNotFoundException { Preconditions.checkNotNull(context); Preconditions.checkState(!Strings.isNullOrEmpty(architectureCode), "an architecture code is required to get the architecture"); return Architecture.tryGetByCode(context, architectureCode).orElseThrow( () -> new ObjectNotFoundException(Architecture.class.getSimpleName(), architectureCode)); }
From source file:app.philm.in.controllers.BaseController.java
public final void suspend() { Preconditions.checkState(mInited == true, "Not inited"); onSuspended(); mInited = false; }
From source file:org.xacml4j.spring.FunctionProvider.java
public void setProviderClass(Class<FunctionProvider> providerClazz) { Preconditions.checkState(providerInstance == null, "Either provider instance or class must be specified but not both"); this.providerClass = providerClazz; }
From source file:org.opendaylight.controller.cluster.datastore.ReadWriteShardDataTreeTransaction.java
@Override void abort() { Preconditions.checkState(close(), "Transaction is already closed"); parent.abortTransaction(this); }
From source file:io.v.v23.rpc.StreamIterable.java
@Override public synchronized Iterator<T> iterator() { Preconditions.checkState(!isCreated, "Can only create one iterator."); isCreated = true;//from ww w . j a v a 2s .co m return new AbstractIterator<T>() { @Override protected T computeNext() { try { return (T) VFutures.sync(stream.recv(type)); } catch (EndOfFileException e) { // legitimate end of stream return endOfData(); } catch (CanceledException e) { // context canceled return endOfData(); } catch (VException e) { error = e; return endOfData(); } } }; }