[ 
https://issues.apache.org/jira/browse/LANG-1712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17774388#comment-17774388
 ] 

Marc Cappelletti commented on LANG-1712:
----------------------------------------

Hello,

This class allows build an equals method by using method reference.

As the builder is typed, it does the class and null checks and then appends
through the method references.
It results in a more complete and concise equals building:

        @Override
        public boolean equals(Object obj) {
            return new TypedEqualsBuilder<>(this, obj)
                    .append(TestObject::getA)
                    .append(TestObject::getB)
                    .isEquals();
        }

With the actual EqualsBuilder to make it complete, it's longer:

        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }

            TestObject that = (TestObject) o;
            return new EqualsBuilder()
                    .append(getA(), that.getA())
                    .append(getB(), that.getB())
                    .isEquals();
        }

Regards,

Marc

Le mer. 11 oct. 2023 à 17:38, Elliotte Rusty Harold (Jira) <[email protected]>



> Complete the EqualsBuilder to manage type equivalence
> -----------------------------------------------------
>
>                 Key: LANG-1712
>                 URL: https://issues.apache.org/jira/browse/LANG-1712
>             Project: Commons Lang
>          Issue Type: New Feature
>    Affects Versions: 3.13.0
>            Reporter: Marc Cappelletti
>            Priority: Minor
>
> Extend the EqualsBuilder to manage the nullity and the class equality when 
> building and equals method.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to