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.mayocat.addons.ListAddonTransformer.java

@Override
public Optional<AddonFieldValueWebObject> toWebView(EntityData<?> entityData, AddonFieldDefinition addonField,
        Object fieldValue) {/*from w ww  .  j  a va2  s .  c o m*/
    List<String> values = (List<String>) fieldValue;
    List<String> displayValues = Lists.newArrayList();
    List<Map<String, Object>> listValues = getListValues(addonField);
    for (final String value : values) {
        Optional<Map<String, Object>> definition = FluentIterable.from(listValues)
                .filter(new Predicate<Map<String, Object>>() {
                    public boolean apply(Map<String, Object> input) {
                        return input.containsKey("key") && input.get("key").equals(value.toString());
                    }
                }).first();
        displayValues.add(definition.isPresent() && definition.get().containsKey("name")
                ? (String) definition.get().get("name")
                : value);
    }
    return Optional.of(new AddonFieldValueWebObject(fieldValue, displayValues));
}

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

@Nonnull
public static FluentIterable<Node> asIterable(@Nonnull Node[] nodes) {
    return FluentIterable.from(Arrays.asList(nodes));
}

From source file:org.mayocat.accounts.store.memory.MemoryTenantStore.java

public Tenant findByDefaultHost(String host) {
    return FluentIterable.from(findAll(0, 0)).filter(withDefaultHost(host)).first().orNull();
}

From source file:de.flapdoodle.guava.Transformations.java

public static <S, D, C extends Iterable<? extends D>> Iterable<? extends D> flatmap(
        Iterable<? extends S> source, Function<? super S, C> transformation) {
    //Folds.foldLeft(source, Folds.asIterableFold(transformation), ImmutableList.<D> of());
    return FluentIterable.from(source).transformAndConcat(transformation);
}

From source file:dagger.internal.codegen.writer.Snippet.java

@Override
public final Set<ClassName> referencedClasses() {
    return FluentIterable.from(types()).transformAndConcat(new Function<TypeName, Set<ClassName>>() {
        @Override/*from ww  w .ja va 2 s.co m*/
        public Set<ClassName> apply(TypeName input) {
            return input.referencedClasses();
        }
    }).toSet();
}

From source file:com.arcbees.vcs.github.util.GitHubPullRequestsTypeAdapter.java

@Override
public GitHubPullRequests deserialize(JsonElement json, Type typeOfT, final JsonDeserializationContext context)
        throws JsonParseException {
    JsonArray jsonArray = json.getAsJsonArray();

    List<GitHubPullRequest> pullRequests = FluentIterable.from(jsonArray)
            .transform(new Function<JsonElement, GitHubPullRequest>() {
                @Override//  w w w  .j a v a2 s. c  o m
                public GitHubPullRequest apply(JsonElement input) {
                    return context.deserialize(input, GitHubPullRequest.class);
                }
            }).toImmutableList();

    GitHubPullRequests gitHubPullRequests = new GitHubPullRequests();
    gitHubPullRequests.setPullRequests(pullRequests);

    return gitHubPullRequests;
}

From source file:com.facebook.buck.java.intellij.ParsingJavaPackageFinder.java

/**
 * Creates a hybrid {@link JavaPackageFinder} which will resolve packages for the selected paths
 * based on parsing the source files and use the fallbackPackageFinder for everything else.
 *
 * @param javaFileParser parser to read Java sources with.
 * @param projectFilesystem filesystem.//from   w  ww .  ja  v  a2 s  .  c o m
 * @param filesToParse set of files to parse.
 * @param fallbackPackageFinder package finder to use when the package can't be inferred from
 *                              source.
 * @return the described PackageFinder.
 */
public static JavaPackageFinder preparse(final JavaFileParser javaFileParser,
        ProjectFilesystem projectFilesystem, ImmutableSet<Path> filesToParse,
        JavaPackageFinder fallbackPackageFinder) {
    PackagePathCache packagePathCache = new PackagePathCache();
    for (Path path : FluentIterable.from(filesToParse).toSortedSet(new PathComponentCountOrder())) {
        Optional<String> packageNameFromSource = Optionals.bind(projectFilesystem.readFileIfItExists(path),
                new Function<String, Optional<String>>() {
                    @Override
                    public Optional<String> apply(String input) {
                        return javaFileParser.getPackageNameFromSource(input);
                    }
                });
        if (packageNameFromSource.isPresent()) {
            Path javaPackagePath = findPackageFolderWithJavaPackage(packageNameFromSource.get());
            packagePathCache.insert(path, javaPackagePath);
        }
    }
    return new CacheBasedPackageFinder(fallbackPackageFinder, packagePathCache);
}

From source file:org.fenixedu.academic.domain.accessControl.ProfessorsGroup.java

@Override
public Set<User> getMembers() {
    return FluentIterable.from(Bennu.getInstance().getProfessorshipsSet())
            .transform(new Function<Professorship, User>() {
                @Override/* w  ww .  j  a  v  a2 s . c om*/
                public User apply(Professorship input) {
                    return input.getPerson().getUser();
                }
            }).filter(Predicates.notNull()).toSet();
}

From source file:com.example.ModelWithAnonymousClass.java

public ModelWithAnonymousClass() {
    images = FluentIterable.from(Arrays.asList("/image/1")).transform(new Function<String, String>() {
        @Override//from  w  ww .java2 s  . c o m
        public String apply(String path) {
            return resourceResolver.getResource(path).getValueMap().get("property", String.class);
        }
    }).filter(Predicates.notNull()).toList();
}

From source file:ec.tss.tsproviders.TsProviders.java

/**
 * Returns a list of all the Ts providers currently registered in TsFactory.
 *
 * @return/*  w  w w .j a va 2 s  .  c  o m*/
 */
@Nonnull
public static FluentIterable<ITsProvider> all() {
    return FluentIterable.from(asList());
}