commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tomasz Nurkiewicz (JIRA)" <j...@apache.org>
Subject [jira] Commented: (BEANUTILS-375) Provide static methods to simplify usage of BeanToPropertyValueTransformer with CollectionUtils
Date Thu, 06 May 2010 20:53:48 GMT

    [ https://issues.apache.org/jira/browse/BEANUTILS-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12864923#action_12864923
] 

Tomasz Nurkiewicz commented on BEANUTILS-375:
---------------------------------------------

Example usage of  this utility method has been explained here: http://nurkiewicz.blogspot.com/2010/05/clean-code-clean-logs-do-you-know-what.html.

> Provide static methods to simplify usage of BeanToPropertyValueTransformer with CollectionUtils
> -----------------------------------------------------------------------------------------------
>
>                 Key: BEANUTILS-375
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-375
>             Project: Commons BeanUtils
>          Issue Type: Improvement
>          Components: Bean-Collections
>    Affects Versions: 1.8.3
>            Reporter: Tomasz Nurkiewicz
>            Priority: Trivial
>         Attachments: BeanToPropertyValueTransformer.java
>
>
> Provide static {{BeanToPropertyValueTransformer#collect}} methods to simplify the usage
of {{BeanToPropertyValueTransformer}} with {{CollectionUtils#collect}}. See attached implementation.
This is how such a utility method could be used (pay attention to static import):
> {code}import org.junit.Test;
> import java.util.Arrays;
> import java.util.Collection;
> import java.util.List;
> import java.util.Locale;
> import static org.apache.commons.beanutils.BeanToPropertyValueTransformer.collect;
> import static org.fest.assertions.Assertions.assertThat;
> public class TestCollect {
> 	@Test
> 	public void proofOfConcept() throws Exception {
> 		//given
> 		List<Locale> locales = Arrays.asList(
> 				Locale.FRANCE,
> 				Locale.GERMANY,
> 				Locale.ITALY,
> 				new Locale("pl", "PL"));
> 		//when: calls Locale.getCounty() on each item
> 		Collection countries = collect(locales, "country");
> 		//then
> 		assertThat(countries).containsOnly("FR", "DE", "IT", "PL");
> 	}
> }{code}
> Without proposed method:
> {code}Collection countries = CollectionUtils.collect(locales, new BeanToPropertyValueTransformer("country")){code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message