Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-395

annotations based builders

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • Review Patch
    • lang.builder.*
    • None

    Description

      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); }

      }

      Attachments

        1. LANG-395.patch
          58 kB
          J. Taylor Mayfield

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jogi Jörg Gottschling
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: