commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LANG-395) annotations based builders
Date Tue, 12 Nov 2013 05:38:17 GMT

     [ https://issues.apache.org/jira/browse/LANG-395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Henri Yandell updated LANG-395:
-------------------------------

    Fix Version/s:     (was: Patch Needed)
                   Review Patch

> annotations based builders
> --------------------------
>
>                 Key: LANG-395
>                 URL: https://issues.apache.org/jira/browse/LANG-395
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.builder.*
>            Reporter: Jörg Gottschling
>             Fix For: Review Patch
>
>         Attachments: LANG-395.patch
>
>
> What about enabling the builders (ToStringBuilder, EqualsBuilder, etc.) that use reflection
to use annotations to find the field to include?
> Something like:
> ToStringBuilder.annotationsBasedToString(Object object, Class<Annotation> class,
Class<?> reflectUpToClass)
> One could use the JPA-Annotation @ID for example, espescially for Equals- and HashCodeBuilder.
There should also be some default annotation comming with LangTwo.
> Usage:
> public class User
> {
>   @StringRepresentation
>   @EqualsAndHashCode
>   private String name
>   @StringRepresentation
>   private String email;
>   private String password;
>   // ...
>   @Override
>   public String toString()
>   {
>     return annotationsBasedToString(this);
>   }
>   @Override
>   public boolean equals(Object other)
>   {
>     return annotationsBasedEquals(this, other);
>   }
>   @Override
>   public int hashCode()
>   {
>     return annotationsBasedHashCode(this);
>   }
> }



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message