Add TypedEqualsBuilder class and test
This class allows to have a more complete equals builder that takes in consideration the null and class comparison before the appended fields. It makes the equals method more compact.
Change looks quite good and complete. Not sure about the size, it might require a Apache contributor agreement. With this PR and Dev mail you probably don’t need an extra JIRA (or a committer can do that).
Do you have an contributors agreement on file, by any chance? https://www.apache.org/licenses/contributor-agreements.html
Hello @Cousnouf
Please run mvn locally and fix issues before you push to avoid broken builds.
I've addressed the comments. This version may tend to something better :)
Hello all,
I've added some changes to address your comments.
It's still in a separate class as I think it's better to separate the concept of EqualsBuilder with concrete values passed each time with append and the concept of TypedEqualsBuilder which receive the two objects in the construction and then calls the failable function during each appending.
Inputs welcome :)
Regards,
Marc
Le jeu. 28 sept. 2023 à 15:39, Gary Gregory @.***> a écrit :
@.**** commented on this pull request.
In src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java https://github.com/apache/commons-lang/pull/1114#discussion_r1340174101:
Typical use for the code is as follows:
- public boolean equals(Object obj) {
return new TypedEqualsBuilder<>(this)
.appendBaseObject(obj)
.append(TestObject::getA)
.append(TestObject::getB)
.isEquals();
}
- @param <T> the type of the compared object.
- @since 3.14.0
- */ +public class TypedEqualsBuilder<T> extends EqualsBuilder {
It is the class type. its refering to the T class parameter which is supported by this Builder subtype.
✅️ Thanks for pointing that out! 👍
— Reply to this email directly, view it on GitHub https://github.com/apache/commons-lang/pull/1114#discussion_r1340174101, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATRSC2QF3DIIJVO5GMIKO3X4V4ZLANCNFSM6AAAAAA5FT7FAY . You are receiving this because you were mentioned.Message ID: @.***>