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:dagger.internal.codegen.DependencyRequestMapper.java

/**
 * Returns the framework class to use for a collection of requests of the same {@link BindingKey}.
 * This allows factories to only take a single argument for multiple requests of the same key.
 *//*from w  w w.  ja va 2 s .c o m*/
Class<?> getFrameworkClass(Iterable<DependencyRequest> requests) {
    ImmutableSet<Class<?>> classes = FluentIterable.from(requests)
            .transform(new Function<DependencyRequest, Class<?>>() {
                @Override
                public Class<?> apply(DependencyRequest request) {
                    return getFrameworkClass(request);
                }
            }).toSet();
    if (classes.size() == 1) {
        return getOnlyElement(classes);
    } else if (classes.equals(ImmutableSet.of(Producer.class, Provider.class))) {
        return Provider.class;
    } else {
        throw new IllegalStateException("Bad set of framework classes: " + classes);
    }
}

From source file:org.eclipse.buildship.ui.view.task.TaskViewActionStateRules.java

/**
 * Determines whether the actions related to task execution should be enabled or disabled.
 *
 * @param nodeSelection the node selection based on which to make the decision
 * @return {@code true} if actions related to task execution should be enabled
 *///from w  w w.  j  a  v  a 2 s.  c o  m
public static boolean taskScopedTaskExecutionActionsEnabledFor(NodeSelection nodeSelection) {
    // short-circuit in case the selection is empty
    if (nodeSelection.isEmpty()) {
        return false;
    }

    // execution is enabled only if no tasks from included builds are selected and each task is from the same project
    List<?> elements = nodeSelection.toList();
    List<TaskNode> taskNodes = FluentIterable.from(elements).filter(TaskNode.class).toList();
    if (elements.size() != taskNodes.size() || hasMultipleOrIncludedParentProject(taskNodes)) {
        return false;
    }

    // if project tasks are selected only then the execution should be permitted
    List<ProjectTaskNode> projectNodes = FluentIterable.from(elements).filter(ProjectTaskNode.class).toList();
    if (projectNodes.size() == taskNodes.size()) {
        return true;
    }

    // if task selectors are selected only then the execution should be permitted if the root project can be found
    List<TaskSelectorNode> taskSelectorNodes = FluentIterable.from(elements).filter(TaskSelectorNode.class)
            .toList();
    if (taskSelectorNodes.size() == taskNodes.size()) {
        return canFindRootProjects(taskSelectorNodes);
    }

    // as a default disable the execution
    return false;
}

From source file:springfox.documentation.service.SecurityScheme.java

protected void addValidVendorExtensions(List<VendorExtension> vendorExtensions) {
    this.vendorExtensions.addAll(
            FluentIterable.from(nullToEmptyList(vendorExtensions)).filter(new Predicate<VendorExtension>() {
                @Override//from   w w  w .j  a  v  a2s . c om
                public boolean apply(VendorExtension input) {
                    return input.getName().toLowerCase().startsWith("x-");
                }
            }).toList());
}

From source file:org.apache.james.transport.util.MailAddressUtils.java

private static FluentIterable<InternetAddress> iterableOfInternetAddress(List<MailAddress> mailAddresses) {
    return FluentIterable.from(mailAddresses).transform(new Function<MailAddress, InternetAddress>() {

        @Override/*from  w  w w .j a v  a 2s .  c  o  m*/
        public InternetAddress apply(MailAddress mailAddress) {
            return mailAddress.toInternetAddress();
        }
    });
}

From source file:org.sonar.server.computation.task.projectanalysis.metric.ReportMetricValidatorImpl.java

public ReportMetricValidatorImpl(ScannerMetrics scannerMetrics) {
    this.metricByKey = FluentIterable.from(scannerMetrics.getMetrics()).uniqueIndex(MetricToKey.INSTANCE);
}

From source file:org.apache.isis.viewer.wicket.ui.components.layout.bs3.tabs.TabGroupPanel.java

private static List<ITab> tabsFor(final EntityModel entityModel) {
    final List<ITab> tabs = Lists.newArrayList();

    final BS3TabGroup tabGroup = (BS3TabGroup) entityModel.getLayoutMetadata();
    final List<BS3Tab> tablist = FluentIterable.from(tabGroup.getTabs()).filter(BS3Tab.Predicates.notEmpty())
            .toList();//  ww w.ja  v  a2 s . c  o  m

    for (final BS3Tab bs3Tab : tablist) {
        final RepeatingViewWithDynamicallyVisibleContent rv = TabPanel.newRows(entityModel, bs3Tab);
        String translateContext = entityModel.getTypeOfSpecification().getFullIdentifier();
        String bs3TabName = bs3Tab.getName();
        String tabName = getTranslationService().translate(translateContext, bs3TabName);
        tabs.add(new AbstractTab(Model.of(tabName)) {
            private static final long serialVersionUID = 1L;

            @Override
            public Panel getPanel(String panelId) {
                return new TabPanel(panelId, entityModel, bs3Tab, rv);
            }

            @Override
            public boolean isVisible() {
                return rv.isVisible();
            }
        });
    }
    return tabs;
}

From source file:com.gwtplatform.dispatch.rest.shared.RestActionDecorator.java

@Override
public List<HttpParameter> getParameters(final Type type) {
    return FluentIterable.from(extraParams).filter(parameter -> parameter.getType() == type)
            .append(action.getParameters(type)).toList();
}

From source file:br.com.caelum.vraptor.interceptor.WithAnnotationAcceptor.java

private boolean containsAllowedTypes(Annotation[] annotations) {
    return FluentIterable.from(asList(annotations)).anyMatch(isAllowedType());
}

From source file:net.sourceforge.fenixedu.domain.cms.SiteTemplate.java

public List<TemplatedSection> getOrderedSections() {
    return FluentIterable.from(getTemplatedSectionSet()).filter(new Predicate<TemplatedSection>() {
        @Override// w w w .  ja  va 2s  . co  m
        public boolean apply(TemplatedSection input) {
            return input.getVisible();
        }
    }).toSortedList(Ordering.natural());
}

From source file:org.parceler.internal.matcher.GenericCollectionMatcher.java

@Override
public boolean matches(ASTType input) {

    return collectionMatcher.matches(input) && input.getGenericParameters().size() == parameterCount
            && FluentIterable.from(input.getGenericParameters()).allMatch(new Predicate<ASTType>() {
                public boolean apply(ASTType astType) {
                    return generators.matches(astType);
                }//from w w w.  j  a v a2 s  . c om
            });
}