List of usage examples for com.google.common.collect Iterables isEmpty
public static boolean isEmpty(Iterable<?> iterable)
From source file:com.google.devtools.build.skyframe.QueryableGraphBackedSkyFunctionEnvironment.java
private static ValueOrUntypedException toUntypedValue(NodeEntry nodeEntry) throws InterruptedException { if (nodeEntry == null || !nodeEntry.isDone()) { return ValueOrExceptionUtils.ofNull(); }// w w w .j a v a 2 s . c o m SkyValue maybeWrappedValue = nodeEntry.getValueMaybeWithMetadata(); SkyValue justValue = ValueWithMetadata.justValue(maybeWrappedValue); if (justValue != null) { return ValueOrExceptionUtils.ofValueUntyped(justValue); } ErrorInfo errorInfo = Preconditions.checkNotNull(ValueWithMetadata.getMaybeErrorInfo(maybeWrappedValue)); Exception exception = errorInfo.getException(); if (exception != null) { // Give SkyFunction#compute a chance to handle this exception. return ValueOrExceptionUtils.ofExn(exception); } // In a cycle. Preconditions.checkState(!Iterables.isEmpty(errorInfo.getCycleInfo()), "%s %s", errorInfo, maybeWrappedValue); return ValueOrExceptionUtils.ofNull(); }
From source file:de.cosmocode.commons.validation.FalseRule.java
@Override public boolean all(Iterable<? extends Object> inputs) { Preconditions.checkNotNull(inputs, "Inputs"); return Iterables.isEmpty(inputs); }
From source file:com.freiheit.fuava.simplebatch.result.ComposedResult.java
/** * If there are no results, fail. If there is one successful result, return * success. Add warnings for any values that exceed. */// w w w . j av a2 s . c om public Result<A, B> compose(final Iterable<? extends Result<?, B>> results) { if (results == null || Iterables.isEmpty(results)) { return builder.withFailureMessage( "No intermediate results found. Intermediate input was " + intermediateValue).failed(); } final Result<?, B> firstSuccess = Iterables.find(results, Result::isSuccess); for (final Result<?, B> r : results) { // add everything that was accumulated in the composed results builder.withFailureMessages(r.getFailureMessages()).withWarningMessages(r.getWarningMessages()) .withThrowables(r.getThrowables()); } if (firstSuccess == null) { return builder.failed(); } return builder.withOutput(firstSuccess.getOutput()).success(); }
From source file:eu.numberfour.n4js.scoping.utils.DynamicPseudoScope.java
@Override public Iterable<IEObjectDescription> getElements(QualifiedName name) { Iterable<IEObjectDescription> parentResult = parent.getElements(name); if (Iterables.isEmpty(parentResult)) { return Collections.<IEObjectDescription>singletonList(new UnresolvableObjectDescription(name)); }//from w ww .ja v a 2s .c om return parentResult; }
From source file:org.sosy_lab.cpachecker.cfa.ast.FileLocation.java
public static FileLocation merge(List<FileLocation> locations) { checkArgument(!Iterables.isEmpty(locations)); String fileName = null;/* w w w .j a v a2 s .c om*/ String niceFileName = null; int startingLine = Integer.MAX_VALUE; int startingLineInOrigin = Integer.MAX_VALUE; int endingLine = Integer.MIN_VALUE; for (FileLocation loc : locations) { if (loc == DUMMY) { continue; } if (fileName == null) { fileName = loc.fileName; niceFileName = loc.niceFileName; } else if (!fileName.equals(loc.fileName)) { return MULTIPLE_FILES; } startingLine = Math.min(startingLine, loc.getStartingLineNumber()); startingLineInOrigin = Math.min(startingLineInOrigin, loc.getStartingLineInOrigin()); endingLine = Math.max(endingLine, loc.getEndingLineNumber()); } if (fileName == null) { // only DUMMY elements return DUMMY; } return new FileLocation(endingLine, fileName, niceFileName, 0, 0, startingLine, startingLineInOrigin); }
From source file:com.vino.business.CellarBusiness.java
public WineCellar removeCellar(String cellarKey) { Iterable<WineCellarRecord> allRecords = repository.getAllRecords(Reference.<WineCellar>of(cellarKey)); if (!Iterables.isEmpty(allRecords)) { throw new IllegalStateException("CELLAR_NOT_EMPTY"); }/*from w w w .j a va 2 s . c om*/ persistor.delete(cellarKey); return (WineCellar) new WineCellar().setKey(cellarKey); }
From source file:com.spectralogic.ds3cli.views.cli.GetVersionedBucketView.java
@Override public String render(final GetBucketResult br) { // Bucket details final String bucketDesc = new GetBucketDetailsView().render(br); if (null == br.getResult() || Iterables.isEmpty(br.getResult())) { return "No objects were reported in bucket."; }/*from w w w . j a v a2 s . co m*/ this.contents = br.getResult(); initTable(ImmutableList.of("File Name", "Size", "Owner", "Last Modified", "ETag", "Version Id")); setTableDataAlignment(ImmutableList.of(ASCIITable.ALIGN_LEFT, ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_LEFT, ASCIITable.ALIGN_RIGHT, ASCIITable.ALIGN_LEFT)); final String bucketContents = ASCIITable.getInstance().getTable(getHeaders(), formatTableContents()); return String.format("%s\n%s", bucketDesc, bucketContents); }
From source file:com.google.api.server.spi.config.model.ApiCacheControlConfig.java
@Override public boolean equals(Object o) { if (this == o) { return true; } else if (o instanceof ApiCacheControlConfig) { ApiCacheControlConfig config = (ApiCacheControlConfig) o; return Iterables.isEmpty(getConfigurationInconsistencies(config)); } else {/*from w ww. j ava 2 s. c o m*/ return false; } }
From source file:minium.web.internal.actions.RetryAfterWaitingWhileEmptyInteractionListener.java
@Override protected void onAfterFailEvent(AfterFailInteractionEvent event) { if (!(event.getException() instanceof TimeoutException)) return;/*ww w . j a v a2 s . co m*/ if (Iterables.isEmpty(waitElements.as(InternalWebElements.class).wrappedNativeElements())) { try { WaitForExistenceInteraction interaction = new WaitForExistenceInteraction(waitElements, null); interaction.registerListener(new WaitingPresetInteractionListener(waitingPreset)); interaction.perform(); event.setRetry(true); } catch (Exception e) { // we tried... } } }
From source file:org.pantsbuild.tools.junit.impl.SpecParser.java
/** * Parses the list of incoming test specs from the command line. * <p>/* w w w . j av a 2 s . c om*/ * Expects a list of string specs which can be represented as one of: * <ul> * <li>package.className</li> * <li>package.className#methodName</li> * </ul> * Note that each class or method will only be executed once, no matter how many times it is * present in the list. * </p> * <p> * It is illegal to pass a spec with just the className if there are also individual methods * present in the list within the same class. * </p> */ // TODO(zundel): This could easily be extended to allow a regular expression in the spec SpecParser(Iterable<String> testSpecStrings) { Preconditions.checkArgument(!Iterables.isEmpty(testSpecStrings)); this.testSpecStrings = testSpecStrings; }