List of usage examples for com.google.common.collect FluentIterable from
@Deprecated @CheckReturnValue public static <E> FluentIterable<E> from(FluentIterable<E> iterable)
From source file:org.mayocat.cms.news.store.memory.MemoryArticleStore.java
public Article findBySlug(String slug) { return FluentIterable.from(all()).filter(withSlug(slug)).first().orNull(); }
From source file:ec.tss.tsproviders.sdmx.engine.FluentDom.java
@Deprecated public static FluentIterable<Node> childNodes(Node node) { return FluentIterable.from(asList(node.getChildNodes())); }
From source file:ezbake.thrift.authentication.X509Utils.java
private static Iterable<String> getValueOfType(final LdapName name, final DnFields type) { Preconditions.checkNotNull(name, "principal name must not be null"); Set<String> values = Sets.newHashSet(FluentIterable.from(name.getRdns()).filter(new Predicate<Rdn>() { @Override/*from ww w . j av a 2s .c o m*/ public boolean apply(Rdn rdn) { return rdn.getType().equals(type.toString()); } }).transform(new Function<Rdn, String>() { @Override public String apply(Rdn rdn) { return rdn.getValue().toString(); } })); return values; }
From source file:org.mayocat.cms.pages.store.memory.MemoryPageStore.java
@Override public List<Page> findAllRootPages() { return FluentIterable.from(all()).filter(withParent(null)).toList(); }
From source file:com.arpnetworking.clusteraggregator.AggDataUnifier.java
/** * Unifies <code>AggregatedData</code> units. * @param aggData List of <code>AggregatedData</code> to unify. * @return A new {@code List<AggregatedData>} with unified units. */// ww w . j a v a 2 s. co m public static List<AggregatedData> unify(final Collection<AggregatedData> aggData) { Optional<Unit> smallestUnit = Optional.absent(); for (final AggregatedData data : aggData) { smallestUnit = getSmaller(smallestUnit, data.getValue().getUnit()); for (final Quantity quantity : data.getSamples()) { smallestUnit = getSmaller(smallestUnit, quantity.getUnit()); } } return FluentIterable.from(aggData).transform(new ConvertUnitTransform(smallestUnit)).toList(); }
From source file:org.apache.james.transport.matchers.utils.MailAddressCollectionReader.java
public static Set<MailAddress> read(String condition) { Preconditions.checkArgument(!Strings.isNullOrEmpty(condition)); return FluentIterable.from(Splitter.onPattern("(,| |\t)").split(condition)).filter(new Predicate<String>() { @Override/* w w w . j a va 2s . c o m*/ public boolean apply(String s) { return !Strings.isNullOrEmpty(s); } }).transform(new Function<String, MailAddress>() { @Override public MailAddress apply(String s) { try { return new MailAddress(s); } catch (AddressException e) { throw Throwables.propagate(e); } } }).toSet(); }
From source file:org.apache.james.transport.mailets.remoteDelivery.AddressesArrayToMailAddressListConverter.java
public static List<MailAddress> getAddressesAsMailAddress(Address[] addresses, final Logger logger) { if (addresses == null) { return ImmutableList.of(); }// w w w. j a va2 s. c om return FluentIterable.from(Arrays.asList(addresses)) .transform(new Function<Address, Optional<MailAddress>>() { @Override public Optional<MailAddress> apply(Address input) { try { return Optional.of(new MailAddress(input.toString())); } catch (AddressException e) { logger.debug("Can't parse unsent address: {}", e.getMessage()); return Optional.absent(); } } }).filter(new Predicate<Optional<MailAddress>>() { @Override public boolean apply(Optional<MailAddress> input) { return input.isPresent(); } }).transform(new Function<Optional<MailAddress>, MailAddress>() { @Override public MailAddress apply(Optional<MailAddress> input) { return input.get(); } }).toList(); }
From source file:org.mayocat.shop.customer.store.memory.MemoryCustomerStore.java
public Customer findBySlug(String slug) { return FluentIterable.from(all()).filter(withSlug(slug)).first().orNull(); }
From source file:org.eclipse.buildship.ui.util.predicate.Predicates.java
public static Predicate<Object> hasGradleNature() { return new Predicate<Object>() { @Override/*from ww w . j a v a2 s .c o m*/ public boolean apply(Object adaptable) { @SuppressWarnings({ "cast", "RedundantCast" }) IProject project = (IProject) Platform.getAdapterManager().getAdapter(adaptable, IProject.class); if (project != null) { return hasGradleNature(project); } else if (adaptable instanceof PackageFragmentRootContainer) { project = ((PackageFragmentRootContainer) adaptable).getJavaProject().getProject(); return hasGradleNature(project); } else if (adaptable instanceof IStructuredSelection) { List<?> selections = ((IStructuredSelection) adaptable).toList(); return FluentIterable.from(selections).anyMatch(hasGradleNature()); } return false; } }; }
From source file:com.facebook.buck.core.cell.name.AbstractRelativeCellName.java
public static RelativeCellName fromComponents(String... strings) { return RelativeCellName.of(FluentIterable.from(strings)); }