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.backends.jpa.JpaTestCluster.java

public static JpaTestCluster create(Class<?>... clazz) {
    HashMap<String, String> properties = new HashMap<String, String>();
    properties.put("openjpa.ConnectionDriverName", org.h2.Driver.class.getName());
    properties.put("openjpa.ConnectionURL", "jdbc:h2:mem:mailboxintegration;DB_CLOSE_DELAY=-1"); // Memory H2 database
    properties.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)"); // Create Foreign Keys
    properties.put("openjpa.jdbc.MappingDefaults",
            "ForeignKeyDeleteAction=restrict, JoinForeignKeyDeleteAction=restrict");
    properties.put("openjpa.jdbc.SchemaFactory", "native(ForeignKeys=true)");
    properties.put("openjpa.jdbc.MappingDefaults",
            "ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade");
    properties.put("openjpa.jdbc.QuerySQLCache", "false");
    properties.put("openjpa.Log", "JDBC=WARN, SQL=WARN, Runtime=WARN");
    properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72");
    properties.put("openjpa.MetaDataFactory", "jpa(Types="
            + Joiner.on(";").join(FluentIterable.from(Arrays.asList(clazz)).transform(toFQDN())) + ")");
    return new JpaTestCluster(OpenJPAPersistence.getEntityManagerFactory(properties));
}

From source file:org.apache.aurora.scheduler.cron.quartz.CronSchedulerImpl.java

@Override
public Optional<CrontabEntry> getSchedule(IJobKey jobKey) throws IllegalStateException {
    requireNonNull(jobKey);/*from   www.  j  a va 2s  . c  o m*/

    try {
        return Optional
                .of(Iterables.getOnlyElement(FluentIterable.from(scheduler.getTriggersOfJob(jobKey(jobKey)))
                        .filter(CronTrigger.class).transform(Quartz::crontabEntry)));
    } catch (SchedulerException e) {
        LOG.error("Error reading job " + JobKeys.canonicalString(jobKey) + " cronExpression Quartz: " + e, e);
        return Optional.absent();
    }
}

From source file:com.facebook.buck.rules.coercer.BuildConfigFieldsTypeCoercer.java

@Override
public BuildConfigFields coerce(Function<Optional<String>, Path> cellRoots, ProjectFilesystem filesystem,
        Path pathRelativeToProjectRoot, Object object) throws CoerceFailedException {
    if (!(object instanceof List)) {
        throw CoerceFailedException.simple(object, getOutputClass());
    }/* ww w.ja v a  2 s .  c  om*/

    List<?> list = (List<?>) object;
    List<String> values = FluentIterable.from(list).transform(new Function<Object, String>() {
        @Override
        public String apply(Object input) {
            if (input instanceof String) {
                return (String) input;
            } else {
                throw new HumanReadableException("Expected string for build config values but was: %s", input);
            }
        }
    }).toList();
    return BuildConfigFields.fromFieldDeclarations(values);
}

From source file:com.facebook.buck.ocaml.OcamlUtil.java

public static ImmutableList<OcamlLibrary> getTransitiveOcamlInput(Iterable<? extends BuildRule> inputs) {

    final DirectedAcyclicGraph<BuildRule> graph = BuildRuleDependencyVisitors
            .getBuildRuleDirectedGraphFilteredBy(inputs, OcamlLibrary.class::isInstance,
                    OcamlLibrary.class::isInstance);

    final ImmutableList<BuildRule> sorted = TopologicalSort.sort(graph);

    return FluentIterable.from(sorted).filter(OcamlLibrary.class).toList();
}

From source file:org.jclouds.ultradns.ws.xml.TrafficControllerPoolListHandler.java

@Override
public FluentIterable<TrafficControllerPool> getResult() {
    return FluentIterable.from(pools.build());
}

From source file:com.tngtech.archunit.library.plantuml.PlantUmlComponent.java

List<PlantUmlComponent> getDependencies() {
    return FluentIterable.from(dependencies).transform(GET_TARGET).toList();
}

From source file:org.mayocat.shop.billing.store.memory.MemoryOrderStore.java

public Order findBySlug(String order) {
    return FluentIterable.from(all()).filter(withSlug(order)).first().orNull();
}

From source file:org.jclouds.ultradns.ws.xml.ResourceRecordListHandler.java

@Override
public FluentIterable<ResourceRecordDetail> getResult() {
    return FluentIterable.from(rrs.build());
}

From source file:google.registry.tools.PendingEscrowCommand.java

@Override
public void run() throws Exception {
    System.out.println(FluentIterable
            .from(SORTER.sortedCopy(checker.getTldsAndWatermarksPendingDepositForRdeAndBrda().values()))
            .transform(Functions.toStringFunction()).join(Joiner.on('\n')));
}

From source file:com.facebook.buck.cxx.FrameworkPathArg.java

@Override
public ImmutableCollection<BuildRule> getDeps(final SourcePathRuleFinder ruleFinder) {
    FluentIterable<SourcePath> sourcePaths = FluentIterable.from(frameworkPaths)
            .transformAndConcat(new Function<FrameworkPath, Iterable<SourcePath>>() {
                @Override/*from   w  w  w.  j  a v a2s. com*/
                public Iterable<SourcePath> apply(FrameworkPath input) {
                    return OptionalCompat.asSet(input.getSourcePath());
                }
            });
    return ruleFinder.filterBuildRuleInputs(sourcePaths);
}