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

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

Introduction

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

Prototype

@CheckReturnValue
public static <F, T> List<T> transform(List<F> fromList, Function<? super F, ? extends T> function) 

Source Link

Document

Returns a list that applies function to each element of fromList .

Usage

From source file:ru.org.linux.comment.CommentNodeBuilder.java

public CommentNode build() {
    return new CommentNode(comment, Lists.transform(childs, new Function<CommentNodeBuilder, CommentNode>() {
        @Override/*  ww  w .j av  a2s  .c o  m*/
        public CommentNode apply(CommentNodeBuilder input) {
            return input.build();
        }
    }));
}

From source file:com.onboard.domain.transform.CommentTransform.java

public static CommentDTO commentAndCreatorToCommentDTO(Comment comment, User creator) {
    CommentDTO commentDTO = new CommentDTO();
    BeanUtils.copyProperties(comment, commentDTO);

    if (creator != null) {
        commentDTO.setCreatorDTO(UserTransform.userToUserDTO(creator));
    }//from  w  ww .java 2  s. c o m
    if (comment.getSubscribers() != null) {
        commentDTO.setSubscriberDTOs(
                Lists.transform(comment.getSubscribers(), UserTransform.USER_TO_USERDTO_FUNCTION));
    }
    if (comment.getAttachments() != null) {
        commentDTO.setAttachmentDTOs(Lists.transform(comment.getAttachments(),
                AttachmentTransform.ATTACHMENT_TO_ATTACHMENTDTO_FUNCTION));
    }
    if (comment.getDiscardAttachments() != null) {
        commentDTO.setDiscardAttachmentDTOs(Lists.transform(comment.getDiscardAttachments(),
                AttachmentTransform.ATTACHMENT_TO_ATTACHMENTDTO_FUNCTION));
    }
    return commentDTO;
}

From source file:com.blacklocus.jres.response.bulk.JresBulkReply.java

public List<String> keys() {
    return Lists.transform(items, new Function<Map<String, Item>, String>() {
        @Override/*from  w w w  . j av  a  2  s  .c  o  m*/
        public String apply(Map<String, Item> action) {
            assert action.size() == 1;
            return action.keySet().iterator().next();
        }
    });
}

From source file:com.google.template.soy.jssrc.dsl.SoyJsPluginUtils.java

/** Generates a JS expression for the given operator and operands. */
public static JsExpr genJsExprUsingSoySyntax(Operator op, List<JsExpr> operandJsExprs) {
    List<CodeChunk.WithValue> operands = Lists.transform(operandJsExprs,
            new Function<JsExpr, CodeChunk.WithValue>() {
                @Override/*from  w w  w. j  a v  a2s.  c o  m*/
                public CodeChunk.WithValue apply(JsExpr input) {
                    return fromExpr(input, ImmutableList.<GoogRequire>of());
                }
            });
    return CodeChunk.operation(op, operands).assertExpr();
}

From source file:fi.vm.sade.eperusteet.amosaa.dto.PageDto.java

public PageDto(final Page<S> source, final Class<D> dstClass, final Pageable page, final DtoMapper mapper) {
    super(new ArrayList<>(Lists.transform(source.getContent(), new Function<S, D>() {
        @Override/*  w  w w . jav a2s  .co m*/
        public D apply(S f) {
            return mapper.map(f, dstClass);
        }
    })), page, source.getTotalElements());
}

From source file:com.luna.sys.group.service.GroupService.java

public Set<Map<String, Object>> findIdAndNames(Searchable searchable, String groupName) {

    searchable.addSearchFilter("name", SearchOperator.like, groupName);

    return Sets.newHashSet(
            Lists.transform(findAll(searchable).getContent(), new Function<Group, Map<String, Object>>() {
                @Override/*from  ww w . ja v a 2s .c o m*/
                public Map<String, Object> apply(Group input) {
                    Map<String, Object> data = Maps.newHashMap();
                    data.put("label", input.getName());
                    data.put("value", input.getId());
                    return data;
                }
            }));
}

From source file:org.mule.raml.impl.v08.model.MimeTypeImpl.java

@Override
public Map<String, TypeFieldDefinition> getFormParameters() {

    return Maps.uniqueIndex(Lists.transform(bodyLike.formParameters(),
            new Function<org.raml.v2.api.model.v08.parameters.Parameter, TypeFieldDefinition>() {
                @Nullable//w  w w .  j  ava2s  .  com
                @Override
                public TypeFieldDefinition apply(
                        @Nullable org.raml.v2.api.model.v08.parameters.Parameter input) {
                    return new ParameterImpl(input);
                }
            }), new Function<TypeFieldDefinition, String>() {
                @Nullable
                @Override
                public String apply(@Nullable TypeFieldDefinition input) {
                    return input.getName();
                }
            });
}

From source file:eu.interedition.collatex.input.WhitespaceTokenizer.java

@Override
public List<String> apply(String input) {
    return Lists.transform(Arrays.asList(input.trim().split("\\s+")), TRIMMER);
}

From source file:ivorius.ivtoolkit.tools.NBTTagLists.java

public static List<int[]> intArrays(final NBTTagList list) {
    return Lists.transform(Ranges.rangeList(0, list.tagCount()), new Function<Integer, int[]>() {
        @Nullable/*w ww  . ja v a2 s.c  o  m*/
        @Override
        public int[] apply(Integer input) {
            return list.func_150306_c(input);
        }
    });
}

From source file:com.dangdang.ddframe.rdb.sharding.router.binding.BindingRoutingResult.java

BindingRoutingResult(final SingleRoutingResult singleRoutingResult) {
    getRoutingDataSources().addAll(Lists.transform(singleRoutingResult.getRoutingDataSources(),
            new Function<SingleRoutingDataSource, BindingRoutingDataSource>() {

                @Override//  ww w  .ja v  a  2 s. c  om
                public BindingRoutingDataSource apply(final SingleRoutingDataSource input) {
                    return new BindingRoutingDataSource(input);
                }
            }));
}