List of usage examples for com.google.common.collect Iterables all
public static <T> boolean all(Iterable<T> iterable, Predicate<? super T> predicate)
From source file:net.bican.iplib.sample.Sample.java
public static void main(String[] args) { // creating a network range by CIDR address CIDR cidr1 = new CIDR("10.10.10.0/30"); Range<IPAddress> range1 = IPAddresses.fromCIDR(cidr1); // iterating a network range Iterables.all(new AddressIterable(range1), new Predicate<IPAddress>() { @Override/*from w w w . j a v a2s . c om*/ public boolean apply(IPAddress input) { System.out.println(input); return true; } }); // creating a network range by netmask Netmask netmask1 = new Netmask("10.10.20.0/255.255.255.0"); Range<IPAddress> range2 = IPAddresses.fromNetmask(netmask1); System.out.println("range contains ip: " + range2.contains(IPAddress.getInstance(InetAddresses.forString("10.10.20.20")))); System.out.println("range contains ip: " + range2.contains(IPAddress.getInstance(InetAddresses.forString("10.10.21.20")))); // creating a network range from an arbitrary interval Range<IPAddress> interval = Range.closed(IPAddress.getInstance(InetAddresses.forString("1.0.0.1")), IPAddress.getInstance(InetAddresses.forString("1.0.2.22"))); Set<Range<IPAddress>> ips = IPAddresses.fromInterval(interval); for (Range<IPAddress> i : ips) { System.out.println(i); } }
From source file:org.trancecode.xml.saxon.SaxonMaps.java
public static Map<QName, String> attributes(final Iterable<XdmNode> attributes) { assert Iterables.all(attributes, SaxonPredicates.isAttribute()); final Map<QName, XdmNode> nodeMap = Maps.uniqueIndex(attributes, SaxonFunctions.getNodeName()); return Maps.transformValues(nodeMap, SaxonFunctions.getStringValue()); }
From source file:org.garethaye.minimax.framework.BotUtils.java
public static boolean allEqual(List<Integer> list, final int value) { return Iterables.all(list, new Predicate<Integer>() { @Override/*from www .ja va2 s . c o m*/ public boolean apply(Integer elt) { return value == elt; } }); }
From source file:com.samskivert.depot.impl.operator.BaseOperator.java
public static <S, T> boolean all(Function<S, T> fun, S... obj) { return Iterables.all(Arrays.asList(obj), Predicates.compose(Predicates.isNull(), fun)); }
From source file:com.analog.lyric.dimple.solvers.sumproduct.customFactors.CustomGaussianSubtract.java
/** * Utility to indicate whether or not a factor is compatible with the requirements of this custom factor * @deprecated as of release 0.08/*from w ww. j a v a 2s .c om*/ */ @Deprecated public static boolean isFactorCompatible(Factor factor) { return Iterables.all(factor.getSiblings(), VariablePredicates.isUnboundedReal()); }
From source file:com.facebook.buck.apple.AppleBundleExtensions.java
public static boolean allPathsHaveValidTestExtensions(Iterable<Path> paths) { return Iterables.all(paths, HAS_VALID_XCTOOL_BUNDLE_EXTENSION); }
From source file:org.apache.aurora.common.base.Closures.java
/** * Combines multiple closures into a single closure, whose calls are replicated sequentially * in the order that they were provided. * If an exception is encountered from a closure it propagates to the top-level closure and the * remaining closures are not executed./* w w w .j a v a 2 s. c o m*/ * * @param closures Closures to combine. * @param <T> Type accepted by the closures. * @return A single closure that will fan out all calls to {@link Closure#execute(Object)} to * the wrapped closures. */ public static <T> Closure<T> combine(Iterable<Closure<T>> closures) { checkNotNull(closures); checkArgument(Iterables.all(closures, Predicates.notNull())); final Iterable<Closure<T>> closuresCopy = ImmutableList.copyOf(closures); return item -> { for (Closure<T> closure : closuresCopy) { closure.execute(item); } }; }
From source file:org.apache.aurora.common.base.Consumers.java
/** * Combines multiple consumers into a single consumer, whose calls are replicated sequentially * in the order that they were provided. * If an exception is encountered from a consumer it propagates to the top-level consumer and the * remaining consumer are not executed.//from w w w . jav a2s. c o m * * @param consumers Consumers to combine. * @param <T> Type accepted by the consumers. * @return A single consumer that will fan out all calls to {@link Consumer#accept(Object)} to * the wrapped consumers. */ public static <T> Consumer<T> combine(List<Consumer<T>> consumers) { checkNotNull(consumers); checkArgument(Iterables.all(consumers, Predicates.notNull())); return consumers.stream().reduce(noop(), Consumer::andThen); }
From source file:com.github.autermann.utils.Optionals.java
/** * A {@link Predicate} to check if all of the supplied {@link Optional}s are * present.// w w w. j av a 2 s .com * * @param <T> the type of the {@link Optional} * * @return the predicate */ public static <T> boolean all(Optional<? extends T>... optionals) { return Iterables.all(Arrays.asList(optionals), isPresent()); }
From source file:com.linkedin.flashback.matchrules.CompositeMatchRule.java
@Override public boolean test(final RecordedHttpRequest incomingRequest, final RecordedHttpRequest expectedRequest) { return Iterables.all(_matchRules, new Predicate<MatchRule>() { @Override/* www . j a v a 2s. com*/ public boolean apply(MatchRule rule) { return rule.test(incomingRequest, expectedRequest); } }); }