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:com.ngdata.hbaseindexer.parse.extract.ExtractTestUtil.java

public static void assertByteArraysEquals(Collection<byte[]> expected, Collection<byte[]> actual) {
    Function<byte[], String> byteToStringFn = new Function<byte[], String>() {

        @Override/*from   ww w.  ja  v  a 2  s.  co  m*/
        public String apply(@Nullable byte[] input) {
            return Bytes.toStringBinary(input);
        }
    };
    assertEquals(Lists.newArrayList(Collections2.transform(expected, byteToStringFn)),
            Lists.newArrayList(Collections2.transform(actual, byteToStringFn)));

}

From source file:org.lightadmin.core.config.domain.field.FieldMetadataUtils.java

public static Set<FieldMetadata> extractFields(Iterable<FilterMetadata> filterMetadatas) {
    return newLinkedHashSet(
            Collections2.transform(newLinkedHashSet(filterMetadatas), new FieldMetadataExtractor()));
}

From source file:am.ik.categolj2.domain.service.userdetails.Categolj2UserDetails.java

private static Collection<? extends GrantedAuthority> toAuthorities(Collection<Role> roles) {
    return Collections2.transform(roles, new Function<Role, SimpleGrantedAuthority>() {
        @Override//w  w w  . jav a  2 s  .  c  om
        public SimpleGrantedAuthority apply(Role role) {
            return new SimpleGrantedAuthority("ROLE_" + role.getRoleName());
        }
    });
}

From source file:org.jtwig.parser.model.JtwigKeyword.java

public static String[] keywords() {
    Collection<String> list = Collections2.transform(asList(JtwigKeyword.values()), extractWord());
    return list.toArray(new String[list.size()]);
}

From source file:com.jayway.demo.library.rest.dto.CustomerDto.java

public static Collection<CustomerDto> fromBeanCollection(Collection<Customer> customers) {
    return Collections2.transform(customers, new Function<Customer, CustomerDto>() {
        @Override/*from   ww w.j  av  a  2  s . c  o  m*/
        public CustomerDto apply(Customer customer) {
            return fromBean(customer);
        }
    });
}

From source file:org.apache.tajo.catalog.FieldConverter.java

public static QualifiedIdentifier toQualifiedIdentifier(String name) {
    final Collection<String> elems = ImmutableList.copyOf(name.split("\\."));
    final Collection<Identifier> identifiers = Collections2.transform(elems,
            new Function<String, Identifier>() {
                @Override/*from w  ww.  java2 s  .  com*/
                public Identifier apply(@Nullable String input) {
                    return Identifier._(input, IdentifierUtil.isShouldBeQuoted(input));
                }
            });
    return QualifiedIdentifier.$(identifiers);
}

From source file:com.ansorgit.plugins.bash.editor.codecompletion.CompletionProviderUtils.java

static Collection<LookupElement> createPsiItems(Collection<? extends PsiNamedElement> elements) {
    return Collections2.transform(elements, new Function<PsiNamedElement, LookupElement>() {
        public LookupElement apply(PsiNamedElement from) {
            return LookupElementBuilder.create(from).withCaseSensitivity(true);
        }//from w w  w .j  a va2  s  . c  om
    });
}

From source file:org.sonar.server.util.LanguageParamUtils.java

public static Collection<String> getLanguageKeys(Languages languages) {
    return Collections2.transform(Arrays.asList(languages.all()), LanguageToKeyFunction.INSTANCE);
}

From source file:io.baku.teslate.PatchSet.java

public <U> PatchSet<U> transform(final Func1<T, U> fn) {
    return new PatchSet<>(frameWidth, frameHeight, Collections2.transform(patches, p -> p.transform(fn)));
}

From source file:org.semanticweb.elk.justifications.andorgraph.AndOrGraphs.java

private static <A> Collection<? extends Node<A>> getDualParents(final Node<A> node) {
    return Collections2.transform(node.getParents(), AndOrGraphs.<A>getDualize());
}