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.jclouds.azurecompute.util.NetworkSecurityGroups.java

public static List<Rule> getCustomRules(final NetworkSecurityGroup networkSecurityGroup) {
    final List<Rule> rules = networkSecurityGroup.rules();
    return FluentIterable.from(rules).filter(Predicates.notNull()).filter(new Predicate<Rule>() {
        @Override/*  www .j av a  2s .c o m*/
        public boolean apply(final Rule rule) {
            return rule.isDefault() == null || !rule.isDefault();
        }
    }).toSortedList(new Comparator<Rule>() {
        @Override
        public int compare(final Rule r1, final Rule r2) {
            final int p1 = Integer.parseInt(r1.priority());
            final int p2 = Integer.parseInt(r2.priority());
            return p1 < p2 ? -1 : p1 == p2 ? 0 : 1;

        }
    });
}

From source file:com.github.lukaszbudnik.gugis.ErrorMessageBuilder.java

public static String buildErrorMessageFromTries(String prefix, List<Try<Object>> tries) {
    List<String> errors = FluentIterable.from(tries).filter(new Predicate<Try<Object>>() {
        @Override//from  w w w .  jav a 2s  . c  o m
        public boolean apply(Try<Object> input) {
            return input.isFailure();
        }
    }).transform(new Function<Try<Object>, String>() {
        @Override
        public String apply(Try<Object> input) {
            return input.failure().toString();
        }
    }).toList();
    return buildErrorMessageFromStrings(prefix, errors);
}

From source file:com.siemens.sw360.commonIO.SampleOptions.java

public static <T extends Enum<T>> String getJoinedOptions(Class<T> clazz) {
    return optionJoiner.join(
            FluentIterable.from(Arrays.asList(clazz.getEnumConstants())).transform(new Function<T, String>() {
                @Override//from w  w  w.j a  v  a  2s.  c  o  m
                public String apply(T input) {
                    return input.name();
                }
            }));
}

From source file:org.apache.isis.core.integtestsupport.ThrowableMatchers.java

public static TypeSafeMatcher<Throwable> causedBy(final Class<?> type) {
    return new TypeSafeMatcher<Throwable>() {
        @Override//w  w  w  . jav a  2s .c  o  m
        protected boolean matchesSafely(final Throwable throwable) {
            final List<Throwable> causalChain = Throwables.getCausalChain(throwable);
            return !FluentIterable.from(causalChain).filter(type).isEmpty();
        }

        @Override
        public void describeTo(final Description description) {
            description.appendText("Caused by " + type.getName());
        }
    };
}

From source file:com.b2international.snowowl.dsl.SCGPostProcessor.java

public static void process(EPackage ePackage) {
    for (EClass eClass : FluentIterable.from(ePackage.getEClassifiers()).filter(EClass.class)) {
        if (CONCEPT_ECLASS_NAME.equals(eClass.getName())) {
            processConcept(eClass);/*  ww w .j  av  a  2s .co m*/
        }
    }
}

From source file:org.eclipse.buildship.core.workspace.internal.LibraryFilter.java

private static IClasspathEntry[] filterLibraries(IClasspathEntry[] classpath) throws JavaModelException {
    return FluentIterable.from(Arrays.asList(classpath)).filter(new Predicate<IClasspathEntry>() {

        @Override/*from w w w .  j a  v a 2s.  c om*/
        public boolean apply(IClasspathEntry entry) {
            return entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY;
        }
    }).toArray(IClasspathEntry.class);
}

From source file:pt.ist.fenixedu.integration.api.beans.publico.FenixDegree.java

private static List<String> getAcademicTerms(final Degree degree) {
    List<String> academicTerms = FluentIterable.from(FluentIterable.from(degree.getExecutionDegrees())
            .transform(new Function<ExecutionDegree, ExecutionYear>() {

                @Override/*from   w  ww  . ja  v a2s  .c  o  m*/
                public ExecutionYear apply(ExecutionDegree input) {
                    return input.getExecutionYear();
                }
            }).toSortedSet(ExecutionYear.REVERSE_COMPARATOR_BY_YEAR))
            .transform(new Function<ExecutionYear, String>() {

                @Override
                public String apply(ExecutionYear input) {
                    return input.getQualifiedName();
                }
            }).toList();
    return academicTerms;
}

From source file:org.eclipse.buildship.ui.util.workbench.WorkingSetUtils.java

/**
 * Converts the given working set names to {@link org.eclipse.ui.IWorkingSet} instances. Filters
 * out working sets that cannot be found by the {@link IWorkingSetManager}.
 *
 * @param workingSetNames the names of the working sets
 * @return the {@link org.eclipse.ui.IWorkingSet} instances
 *//*from ww  w  .  j  av a2s .c o m*/
public static IWorkingSet[] toWorkingSets(List<String> workingSetNames) {
    final IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
    return FluentIterable.from(workingSetNames).transform(new Function<String, IWorkingSet>() {

        @Override
        public IWorkingSet apply(String name) {
            return workingSetManager.getWorkingSet(name);
        }
    }).filter(Predicates.notNull()).toArray(IWorkingSet.class);
}

From source file:google.registry.export.ExportConstants.java

/** Returns the names of kinds to include in datastore backups. */
public static ImmutableSet<String> getBackupKinds() {
    // Back up all entity classes that aren't annotated with @VirtualEntity (never even persisted
    // to datastore, so they can't be backed up) or @NotBackedUp (intentionally omitted).
    return FluentIterable.from(EntityClasses.ALL_CLASSES).filter(not(hasAnnotation(VirtualEntity.class)))
            .filter(not(hasAnnotation(NotBackedUp.class))).transform(CLASS_TO_KIND_FUNCTION)
            .toSortedSet(Ordering.natural());
}

From source file:com.ebay.pulsar.analytics.datasource.DataSourceTypeRegistry.java

public static Set<String> getAllSupportedDataSourceTypes() {
    return FluentIterable.from(factryRegistry.keySet()).transform(new Function<DataSourceTypeEnum, String>() {
        @Override//  w ww . j  a  v  a 2  s  . c  o  m
        public String apply(DataSourceTypeEnum input) {
            if (input != null)
                return input.getType();
            return null;
        }
    }).toSet();
}