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

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

Introduction

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

Prototype

public static <F, T> Collection<T> transform(Collection<F> fromCollection, Function<? super F, T> function) 

Source Link

Document

Returns a collection that applies function to each element of fromCollection .

Usage

From source file:jhc.redsniff.internal.finders.TransformingMFinder.java

private CollectionOf<T> transform(Transformer<E, T> transformer, CollectionOf<E> initial,
        Description couldNotTransformDescription) {
    return CollectionOf.collectionOf(
            Collections2.transform(initial.get(), function(transformer, couldNotTransformDescription)));
}

From source file:com.ning.billing.util.svcapi.tag.DefaultTagInternalApi.java

@Override
public List<TagDefinition> getTagDefinitions(final InternalTenantContext context) {
    return ImmutableList.<TagDefinition>copyOf(Collections2.transform(
            tagDefinitionDao.getTagDefinitions(context), new Function<TagDefinitionModelDao, TagDefinition>() {
                @Override/*from  www. ja va  2  s  .co m*/
                public TagDefinition apply(final TagDefinitionModelDao input) {
                    return new DefaultTagDefinition(input, TagModelDaoHelper.isControlTag(input.getName()));
                }
            }));
}

From source file:com.ning.billing.jaxrs.json.TagDefinitionJson.java

public TagDefinitionJson(final TagDefinition tagDefinition) {
    this(tagDefinition.getId().toString(), tagDefinition.isControlTag(), tagDefinition.getName(),
            tagDefinition.getDescription(), ImmutableList.<String>copyOf(Collections2
                    .transform(tagDefinition.getApplicableObjectTypes(), new Function<ObjectType, String>() {
                        @Override
                        public String apply(@Nullable final ObjectType input) {
                            if (input == null) {
                                return "";
                            } else {
                                return input.toString();
                            }/*  ww  w . j  ava 2  s .  c om*/
                        }
                    })));
}

From source file:org.caleydo.view.domino.api.model.typed.MultiTypedSet.java

@Override
public Set<TypedID> asInhomogenous() {
    if (ids instanceof Single)
        return new SingleTypedIDSet(((Single) ids).set);
    ImmutableSet.Builder<TypedID> b = ImmutableSet.builder();
    for (int i = 0; i < depth(); ++i) {
        IDType idType = idTypes[i];/* ww  w  .  ja va2 s.co m*/
        // select just the slice and map to typed id
        b.addAll(Collections2.transform(ids, Functions.compose(TypedID.toTypedId(idType), slice(i))));
    }
    return b.build();
}

From source file:blue.lapis.pore.impl.entity.PoreComplexLivingEntity.java

@Override
public Set<ComplexEntityPart> getParts() {
    return Sets.newHashSet(Collections2.transform(getHandle().getParts(),
            new Function<ComplexLivingPart, ComplexEntityPart>() {
                @Override// www .j  av a 2s.c o m
                public PoreComplexEntityPart apply(ComplexLivingPart input) {
                    return PoreComplexEntityPart.of(input);
                }
            }));
}

From source file:org.onos.yangtools.yang.data.api.schema.tree.NormalizedNodeDataTreeCandidateNode.java

@Override
public Collection<DataTreeCandidateNode> getChildNodes() {
    if (data instanceof NormalizedNodeContainer) {
        return Collections2.transform(((NormalizedNodeContainer<?, ?, ?>) data).getValue(), FACTORY_FUNCTION);
    } else {//  w  w  w  . j ava 2s  .co m
        return Collections.emptyList();
    }
}

From source file:com.anathema_roguelike.characters.abilities.targetingstrategies.SingleTargeted.java

@Override
public Collection<Point> getValidTargetPoints(Character character) {
    return Collections2.transform(getRange().getTargets(character, getTargetValidator()),
            new Function<Character, Point>() {

                @Override/*from w  w w .  j av a 2 s .  c  o  m*/
                public Point apply(Character target) {
                    return target.getPosition();
                }

            });
}

From source file:com.sonyericsson.hudson.plugins.gerrit.trigger.replication.WaitingForReplication.java

@Override
public String getShortDescription() {
    Collection<String> gerritSlaveNames = Collections2.transform(gerritSlaves, ToGerritSlaveName.INSTANCE);
    return Messages.WaitingForReplication(Joiner.on(", ").join(gerritSlaveNames));
}

From source file:com.atlassian.jira.rest.client.domain.IssueFieldId.java

/**
 * Returns all fields ids./*from w w  w  . j av  a2s.com*/
 * @return List of string id of each field.
 */
public static Iterable<String> ids() {
    return Collections2.transform(ImmutableList.copyOf(IssueFieldId.values()),
            IssueFieldId.TRANSFORM_TO_ID_FUNCTION);
}

From source file:org.lanternpowered.server.inject.impl.reflect.ReflectParameterInfo.java

@SuppressWarnings("unchecked")
public ReflectParameterInfo(AnnotatedElement element, O accessor, Class<T> type) {
    this.annotations = ImmutableList.copyOf(element.getAnnotations());
    this.spec = ParameterSpec.of(type,
            Collections2.transform(this.annotations, anno -> anno.getClass()).toArray(new Class[0]));
    this.accessor = accessor;
    this.element = element;
    this.type = type;
}