You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jörg Gottschling (JIRA)" <ji...@apache.org> on 2008/01/06 17:07:34 UTC

[jira] Created: (LANG-395) annotations based builders

annotations based builders
--------------------------

                 Key: LANG-395
                 URL: https://issues.apache.org/jira/browse/LANG-395
             Project: Commons Lang
          Issue Type: New Feature
    Affects Versions: LangTwo 1.0
            Reporter: Jörg Gottschling
             Fix For: LangTwo 1.0


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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-395) annotations based builders

Posted by "Vincenzo Vitale (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12727165#action_12727165 ] 

Vincenzo Vitale commented on LANG-395:
--------------------------------------

Have a look here:

http://code.google.com/p/simplestuff/

I think it would be easy to port the code (after some review) to commons lang.


Cheers,
V.

> annotations based builders
> --------------------------
>
>                 Key: LANG-395
>                 URL: https://issues.apache.org/jira/browse/LANG-395
>             Project: Commons Lang
>          Issue Type: New Feature
>            Reporter: Jörg Gottschling
>             Fix For: 3.0
>
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-395) annotations based builders

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ 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: LangTwo 1.0
    Affects Version/s:     (was: LangTwo 1.0)

> annotations based builders
> --------------------------
>
>                 Key: LANG-395
>                 URL: https://issues.apache.org/jira/browse/LANG-395
>             Project: Commons Lang
>          Issue Type: New Feature
>            Reporter: Jörg Gottschling
>             Fix For: LangTwo 1.0
>
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-395) annotations based builders

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ 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: 3.0)
                   3.1

Moving to 3.1 as not a backwards-incompatible enhancement, so no need to work hard to get in 3.0.

> 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: 3.1
>
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-395) annotations based builders

Posted by "Jörg Gottschling (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jörg Gottschling updated LANG-395:
----------------------------------

    Fix Version/s:     (was: LangTwo 1.0)

> annotations based builders
> --------------------------
>
>                 Key: LANG-395
>                 URL: https://issues.apache.org/jira/browse/LANG-395
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: LangTwo 1.0
>            Reporter: Jörg Gottschling
>
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.