Matthias Welz created LANG-1657:
-----------------------------------
Summary: DiffBuilder: Type constraint for method append(...,
DiffResult) too strict
Key: LANG-1657
URL: https://issues.apache.org/jira/browse/LANG-1657
Project: Commons Lang
Issue Type: Bug
Components: lang.builder.*
Affects Versions: 3.12.0
Reporter: Matthias Welz
The DiffBuilder<T> has a method append which allows to append an existing
DiffResult for a property. The example illustrates this the following way:
{code:java}
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();
}
}
{code}
However, the signature of the method was recently changed to:
{code:java}
public DiffBuilder<T> append(final String fieldName, final DiffResult<T>
diffResult)
{code}
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:
{code:java}
public <O> DiffBuilder<T> append(final String fieldName, final DiffResult<O>
diffResult)
{code}
or:
{code:java}
public DiffBuilder<T> append(final String fieldName, final DiffResult<?>
diffResult)
{code}
instead.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)