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

DiffBuilder: Type constraint for method append(..., DiffResult) too strict

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.12.0
    • None
    • lang.builder.*
    • None

    Description

      The DiffBuilder<T> has a method append which allows to append an existing DiffResult for a property. The example illustrates this the following way:

       

      public class Person implements Diffable<Person> {
         String name;
         Address address; // implements Diffable<Address>
         ...
         public DiffResult diff(Person obj) {
           return new DiffBuilder(this, obj, ToStringStyle.SHORT_PREFIX_STYLE)
             .append("name", this.name, obj.name)
             .append("address", this.address.diff(obj.address))
             .build();
         }
       }
      

       

      However, the signature of the method was recently changed to:

      public DiffBuilder<T> append(final String fieldName, final DiffResult<T> diffResult)
      

      As a consequence, the example code won't compile anymore when using generics because the a DiffBuilder<Person> will only accept DiffResult<Person> but not DiffResult<Address> for its append method.

      The signature should be:

      public <O> DiffBuilder<T> append(final String fieldName, final DiffResult<O> diffResult)
      

      or:

      public DiffBuilder<T> append(final String fieldName, final DiffResult<?> diffResult)
      

      instead.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            MatthiasWe Matthias Welz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: