commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ondra Žižka (JIRA) <j...@apache.org>
Subject [jira] [Issue Comment Edited] (BEANUTILS-375) Provide static methods to simplify usage of BeanToPropertyValueTransformer with CollectionUtils
Date Sat, 07 May 2011 23:59:03 GMT

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

Ondra Žižka edited comment on BEANUTILS-375 at 5/7/11 11:57 PM:
----------------------------------------------------------------

I would like to have this implemented.

1) IMO that's the most often use case, would be used a lot.

{quote}
It doesn't really add much benefit - it will just mean one line of your code is slightly shorter
{quote}

Well, that's the purpose of commons, isn't it? To save people from writing boilerplate code.
You can write whole application to one line. What is the limit of "slightly"?
It's not about the length of line, it's about making the code more readable.
When someone decides to use {{BeanToPropertyValueTransformer}}, then he usually uses it several
times in a class.
Removing all occurrences of this ugly long name would help improve readability.

Please reconsider this.

      was (Author: pekarna):
    I would like to have this implemented.

1) IMO that's the most often use case, would be used a lot.

{quote}
It doesn't really add much benefit - it will just mean one line of your code is slightly shorter
{quote}

Well, that's the purpose of commons, isn't it? To save people from writing boilerplate code.
You can write whole application to one line. What is the limit of "slightly"?
It's not about the length of line, it's about making the code more readable.
When someone decides to use {{BeanToPropertyValueTransformer)}, then he usually uses it several
times in a class.
Removing all occurences of this ugly long name would help improve readability.

Please reconsider this.
  
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message