Example usage for com.google.common.collect FluentIterable from

List of usage examples for com.google.common.collect FluentIterable from

Introduction

In this page you can find the example usage for com.google.common.collect FluentIterable from.

Prototype

@Deprecated
@CheckReturnValue
public static <E> FluentIterable<E> from(FluentIterable<E> iterable) 

Source Link

Document

Construct a fluent iterable from another fluent iterable.

Usage

From source file:org.apache.james.transport.mailets.remoteDelivery.InternetAddressConverter.java

public static InternetAddress[] convert(Collection<MailAddress> recipients) {
    Preconditions.checkNotNull(recipients);
    return FluentIterable.from(recipients).transform(new Function<MailAddress, InternetAddress>() {
        @Override//from  w w w .  ja  v a2 s  . c om
        public InternetAddress apply(MailAddress input) {
            return input.toInternetAddress();
        }
    }).toArray(InternetAddress.class);
}

From source file:org.raml.jaxrs.converter.model.Utilities.java

public static FluentIterable<RamlMediaType> toRamlMediaTypes(Iterable<javax.ws.rs.core.MediaType> mediaTypes) {
    return FluentIterable.from(mediaTypes).transform(new Function<javax.ws.rs.core.MediaType, RamlMediaType>() {

        @Override//from  w  ww.  j av a2 s  .  co  m
        public RamlMediaType apply(javax.ws.rs.core.MediaType mediaType) {
            return JaxRsRamlMediaType.create(mediaType);
        }
    });
}

From source file:org.opennms.newts.gsod.FileIterable.java

public static FluentIterable<Path> fileTreeWalker(final Path root) {
    return FluentIterable.from(Iterables.concat(groupFilesByDir(root)));
}

From source file:ec.tss.tsproviders.sdmx.engine.FluentDom.java

@Deprecated
public static FluentIterable<Node> elementsByTagName(Document doc, String tagname) {
    return FluentIterable.from(asList(doc.getElementsByTagName(tagname)));
}

From source file:fr.inria.eventcloud.reasoner.SparqlReasoner.java

public static List<SparqlAtomicRequest> parse(String sparqlQuery) throws MalformedSparqlQueryException {
    try {//w  w  w.  j  a v  a2s . c om
        SparqlDecompositionResult sparqlDecompositionResult = SparqlDecomposer.getInstance()
                .decompose(sparqlQuery);

        List<AtomicQuery> atomicQueries = sparqlDecompositionResult.getAtomicQueries();

        List<SparqlAtomicRequest> sparqlAtomicRequests = FluentIterable.from(atomicQueries)
                .transform(new Function<AtomicQuery, SparqlAtomicRequest>() {
                    @Override
                    public SparqlAtomicRequest apply(AtomicQuery input) {
                        return new SparqlAtomicRequest(input);
                    };
                }).toList();

        return sparqlAtomicRequests;
    } catch (DecompositionException e) {
        throw new MalformedSparqlQueryException(sparqlQuery, e);
    }
}

From source file:ec.nbdemetra.ui.nodes.Nodes.java

@Nonnull
public static FluentIterable<Node> childrenIterable(@Nonnull Node root) {
    return FluentIterable
            .from(root.isLeaf() ? Collections.<Node>emptyList() : Arrays.asList(root.getChildren().getNodes()));
}

From source file:org.mayocat.cms.pages.store.memory.MemoryPageStore.java

@Override
public Page findBySlug(String slug) {
    return FluentIterable.from(all()).filter(withSlug(slug)).first().orNull();
}

From source file:fr.javatronic.damapping.intellij.plugin.integration.provider.Common.java

public static boolean hasMapperAnnotation(PsiClass psiClass) {
    if (psiClass.getModifierList() == null || psiClass.getModifierList().getAnnotations() == null) {
        return false;
    }/* ww w. j a v  a 2 s . c  o  m*/

    // look for annotation @Mapper or @com.google.common.base.Function on class
    if (!FluentIterable.from(Arrays.asList(psiClass.getModifierList().getAnnotations()))
            .filter(new Predicate<PsiAnnotation>() {
                @Override
                public boolean apply(@javax.annotation.Nullable PsiAnnotation psiAnnotation) {
                    return psiAnnotation != null && (MAPPER_ANNOTATION_TEXT.equals(psiAnnotation.getText())
                            || MAPPER_QUALIFIED_ANNOTATION_TEXT.equals(psiAnnotation.getText()));
                }
            }).first().isPresent()) {
        return false;
    }

    // look for the import of Guava's Function
    for (PsiElement fileElement : psiClass.getParent().getChildren()) {
        if (fileElement instanceof PsiImportList) {
            for (PsiElement importListElement : fileElement.getChildren()) {
                if (importListElement instanceof PsiImportStatement) {
                    for (PsiElement element : importListElement.getChildren()) {
                        if (element instanceof PsiJavaCodeReferenceElement) {
                            if (Function.class.getName().equals(element.getText())) {
                                return true;
                            }
                        }
                    }
                }

            }
        }
    }
    return false;
}

From source file:tds.student.performance.utils.InitializeSegmentsHelper.java

public static List<OpportunitySegmentInsert> createOpportunitySegmentInsertList(
        List<OpportunitySegmentProperties> propertiesList) {

    Function<OpportunitySegmentProperties, OpportunitySegmentInsert> transform = new Function<OpportunitySegmentProperties, OpportunitySegmentInsert>() {
        @Override/*from  ww  w  .ja v a 2s.  co  m*/
        public OpportunitySegmentInsert apply(OpportunitySegmentProperties input) {
            return new OpportunitySegmentInsert(input);
        }
    };

    return FluentIterable.from(propertiesList).transform(transform).toList();

}

From source file:org.thelq.pircbotx.commands.api.AbstractCommand.java

public static ImmutableSet<AbstractCommand> findAllCommands(ListenerManager manager) {
    return FluentIterable.from(manager.getListeners()).filter(AbstractCommand.class).toSet();
}