Example usage for org.apache.commons.collections4 TransformerUtils invokerTransformer

List of usage examples for org.apache.commons.collections4 TransformerUtils invokerTransformer

Introduction

In this page you can find the example usage for org.apache.commons.collections4 TransformerUtils invokerTransformer.

Prototype

public static <I, O> Transformer<I, O> invokerTransformer(final String methodName) 

Source Link

Document

Gets a Transformer that invokes a method on the input object.

Usage

From source file:com.feilong.core.util.CollectionsUtilTest.java

/**
 * Test collect2./*from  w w  w.ja va 2 s . c  om*/
 */
@Test
public void testCollect2() {
    List<User> list = toList(//
            new User("", 23), new User("", 24), new User("", 25));

    Transformer<User, String> invokerTransformer = TransformerUtils.invokerTransformer("getName");
    List<String> collect1 = CollectionsUtil.collect(list, invokerTransformer);

    assertThat(collect1, hasItems("", "", ""));
}