List of usage examples for com.google.common.collect Iterables isEmpty
public static boolean isEmpty(Iterable<?> iterable)
From source file:com.github.ferstl.maven.pomenforcers.priority.CompoundPriorityOrdering.java
public static <T, P extends Comparable<P>, F extends PriorityOrderingFactory<P, T>> CompoundPriorityOrdering<T, P, F> orderBy( Iterable<F> artifactElements) { if (Iterables.isEmpty(artifactElements)) { throw new IllegalArgumentException("No order specified."); }// w ww. j a va 2 s . c o m return new CompoundPriorityOrdering<>(artifactElements); }
From source file:nextmethod.web.razor.tokenizer.symbols.SymbolExtensions.java
public static LocationTagged<String> getContent(@Nullable final Iterable<? extends ISymbol> symbols, @Nonnull final SourceLocation spanStart) { if (symbols == null || Iterables.isEmpty(symbols)) { return new LocationTagged<>(Strings.Empty, spanStart); } else {//www .j a v a 2 s. c o m final ISymbol first = Iterables.getFirst(symbols, null); final StringBuilder sb = new StringBuilder(); for (ISymbol symbol : symbols) { sb.append(symbol.getContent()); } return new LocationTagged<>(sb.toString(), SourceLocation.add(spanStart, first.getStart())); } }
From source file:org.apache.mahout.math.als.AlternatingLeastSquaresSolver.java
public static Vector solve(Iterable<Vector> featureVectors, Vector ratingVector, double lambda, int numFeatures) { Preconditions.checkNotNull(featureVectors, "Feature Vectors cannot be null"); Preconditions.checkArgument(!Iterables.isEmpty(featureVectors)); Preconditions.checkNotNull(ratingVector, "Rating Vector cannot be null"); Preconditions.checkArgument(ratingVector.getNumNondefaultElements() > 0, "Rating Vector cannot be empty"); Preconditions.checkArgument(Iterables.size(featureVectors) == ratingVector.getNumNondefaultElements()); int nui = ratingVector.getNumNondefaultElements(); Matrix MiIi = createMiIi(featureVectors, numFeatures); Matrix RiIiMaybeTransposed = createRiIiMaybeTransposed(ratingVector); /* compute Ai = MiIi * t(MiIi) + lambda * nui * E */ Matrix Ai = miTimesMiTransposePlusLambdaTimesNuiTimesE(MiIi, lambda, nui); /* compute Vi = MiIi * t(R(i,Ii)) */ Matrix Vi = MiIi.times(RiIiMaybeTransposed); /* compute Ai * ui = Vi */ return solve(Ai, Vi); }
From source file:org.richfaces.cdk.util.MorePredicates.java
public static <S, D> Predicate<D> none(Iterable<S> options, Function<S, Predicate<D>> function) { if (options == null || Iterables.isEmpty(options)) { return Predicates.alwaysTrue(); }// w w w . java 2 s. c om Predicate<D> compositePredicate = Predicates.or(Iterables.transform(options, function)); return Predicates.not(compositePredicate); }
From source file:io.crate.sql.tree.QualifiedName.java
public static QualifiedName of(Iterable<String> parts) { Preconditions.checkNotNull(parts, "parts is null"); Preconditions.checkArgument(!Iterables.isEmpty(parts), "parts is empty"); return new QualifiedName(parts); }
From source file:org.apache.aurora.scheduler.config.validators.NotEmptyIterable.java
@Override public void validate(String name, Iterable<?> value) throws ParameterException { if (Iterables.isEmpty(value)) { throw new ParameterException(String.format("%s must not be empty", name)); }/*from ww w. j a v a2 s. c om*/ }
From source file:nz.co.testamation.core.waiting.WaitForEmpty.java
public WaitForEmpty() { super(new Predicate<T>() { @Override/*from w w w. ja v a2s .co m*/ public boolean apply(T t) { return Iterables.isEmpty(t); } }); }
From source file:nz.co.testamation.core.waiting.WaitForNotEmpty.java
public WaitForNotEmpty() { super(new Predicate<T>() { @Override//from ww w.ja va 2 s . c o m public boolean apply(T t) { return !Iterables.isEmpty(t); } }); }
From source file:org.jpmml.evaluator.BatchUtil.java
/** * Evaluates the model using arguments from the specified CSV resource. * * @return <code>true</code> If there were no differences between expected and actual results, <code>false</code> otherwise. */// w w w . j av a 2 s . c o m static public boolean evaluate(Batch batch, double precision, double zeroThreshold) throws Exception { List<MapDifference<FieldName, ?>> differences = difference(batch, precision, zeroThreshold); return Iterables.isEmpty(differences); }
From source file:google.registry.util.DateTimeUtils.java
/** Returns the earliest element in a {@link DateTime} iterable. */ public static DateTime earliestOf(Iterable<DateTime> dates) { checkArgument(!Iterables.isEmpty(dates)); return Ordering.<DateTime>natural().min(dates); }