Example usage for com.google.common.collect Iterables transform

List of usage examples for com.google.common.collect Iterables transform

Introduction

In this page you can find the example usage for com.google.common.collect Iterables transform.

Prototype

@CheckReturnValue
public static <F, T> Iterable<T> transform(final Iterable<F> fromIterable,
        final Function<? super F, ? extends T> function) 

Source Link

Document

Returns an iterable that applies function to each element of fromIterable .

Usage

From source file:org.sonar.server.computation.task.projectanalysis.step.AbstractComputationSteps.java

@Override
public Iterable<ComputationStep> instances() {
    return Iterables.transform(orderedStepClasses(), input -> {
        ComputationStep computationStepType = container.getComponentByType(input);
        if (computationStepType == null) {
            throw new IllegalStateException(String.format("Component not found: %s", input));
        }//from  w  w w  .  ja va 2 s.  c om
        return computationStepType;
    });
}

From source file:io.fabric8.process.spring.boot.data.service.JpaInvoiceListingService.java

@Override
public Iterable<InvoiceListingRecord> listByQuery(InvoiceQuery query) {
    return Lists.newArrayList(Iterables.transform(invoiceRepository.findByQuery(query),
            new Function<Invoice, InvoiceListingRecord>() {
                @Override// w w w .  j a v a 2s  .  c om
                public InvoiceListingRecord apply(Invoice entity) {
                    InvoiceListingRecord record = new InvoiceListingRecord();
                    record.setListingLabel("Extra label for listing record.");
                    copyProperties(entity, record);
                    return record;
                }
            }));
}

From source file:com.streamreduce.util.HashtagUtil.java

/**
 * Normalizes a Collection of potential hashtags by filtering out all
 * empty/null Strings in the collection and then calls normalizeTag(String) on each remaining String.
 *
 * @param tags a collection of potential tags to normalize.
 * @return a List of normalized Strings from the passed in list, or a modifiable empty List if tags was null.
 *///from w  w  w. j a  v  a 2  s  . c  om
public static List<String> normalizeTags(Collection<String> tags) {
    if (tags == null) {
        return Lists.newArrayList();
    }

    //First filter out null and empty strings
    return Lists.newArrayList(Iterables.transform(Iterables.filter(tags, new Predicate<String>() {
        @Override
        public boolean apply(@Nullable String input) {
            return !StringUtils.isBlank(input);
        }
    }), new Function<String, String>() {
        @Override
        public String apply(@Nullable String input) {
            return normalizeTag(input);
        }
    }));
}

From source file:org.estatio.dom.tag.Tags.java

@Programmatic
public List<String> choices(final Taggable domainObject, final String tagName) {
    final List<Tag> tags = doChoices(domainObject, tagName);
    final Iterable<String> tagNames = Iterables.transform(tags, Tag.GET_VALUE);
    final TreeSet<String> uniqueSortedTagNames = Sets.newTreeSet(tagNames);
    return Lists.newArrayList(uniqueSortedTagNames);
}

From source file:com.exoplatform.iversion.VersionGraph.java

public final Merge<K, V> merge(Set<Long> revisions) {
    return new Merge<K, V>(Iterables.transform(revisions, this));
}

From source file:com.eucalyptus.auth.policy.PolicyPolicy.java

public PolicyPolicy(@Nullable final String policyVersion,
        @Nonnull final List<PolicyAuthorization> authorizations) {
    this.policyVersion = PolicyUtils.intern(policyVersion);
    this.authorizations = ImmutableList
            .copyOf(Iterables.transform(authorizations, PolicyUtils.internAuthorization()));
}

From source file:co.cask.cdap.cli.completer.element.DatasetTypeNameCompleter.java

@Inject
public DatasetTypeNameCompleter(final DatasetTypeClient datasetTypeClient, final CLIConfig cliConfig) {
    super(new Supplier<Collection<String>>() {
        @Override//  www .j  ava 2  s .  c  o m
        public Collection<String> get() {
            try {
                List<DatasetTypeMeta> list = datasetTypeClient.list(cliConfig.getCurrentNamespace());
                return Lists.newArrayList(Iterables.transform(list, new Function<DatasetTypeMeta, String>() {
                    @Override
                    public String apply(DatasetTypeMeta input) {
                        return input.getName();
                    }
                }));
            } catch (IOException e) {
                return Lists.newArrayList();
            } catch (UnauthorizedException e) {
                return Lists.newArrayList();
            }
        }
    });
}

From source file:org.apache.solr.update.MergeIndexesCommand.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder(super.toString());
    Joiner joiner = Joiner.on(",");
    Iterable<String> directories = Iterables.transform(readers, new Function<DirectoryReader, String>() {
        public String apply(DirectoryReader reader) {
            return reader.directory().toString();
        }//from  w ww .  java2 s.  c  o  m
    });
    joiner.skipNulls().join(sb, directories);
    sb.append('}');
    return sb.toString();
}

From source file:org.obiba.opal.web.system.subject.SubjectCredentialsResource.java

@GET
public List<Opal.SubjectCredentialsDto> getAll() {
    return Lists.newArrayList(Iterables.transform(subjectCredentialsService.getSubjectCredentials(),
            new Function<SubjectCredentials, Opal.SubjectCredentialsDto>() {
                @Override/* www . j av a 2 s . c o  m*/
                public Opal.SubjectCredentialsDto apply(SubjectCredentials subjectCredentials) {
                    return Dtos.asDto(subjectCredentials);
                }
            }));
}

From source file:org.gradle.model.internal.manage.schema.cache.MultiWeakClassSet.java

MultiWeakClassSet(List<Class<?>> classes) {
    this.references = Lists.newArrayList(Iterables.transform(classes, TO_WEAK_REF));
    this.hash = classes.hashCode();
}