commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Smiley (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LANG-1330) EqualsBuilder should be able to call custom equals method for specified class
Date Wed, 10 May 2017 15:04:04 GMT

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

Jason Smiley edited comment on LANG-1330 at 5/10/17 3:03 PM:
-------------------------------------------------------------

https://issues.apache.org/jira/browse/LANG-1249 might be sufficient, but, technically the
request here is to be able to call custom equal methods by class type so the burden.

In my implementation, I am technically using 2 different EqualsBuilder instances, so I am
not sure if the bug fix would be enough, but, when I walked through the code, you could see
the ignored fields were lost.

If you have an alternative solution without having to use the root implementation to drive
the equals checks, then I am open to it

ps, gave a few more details on my implementation.


was (Author: jsmiley):
https://issues.apache.org/jira/browse/LANG-1249 might be sufficient, but, technically the
request here is to be able to call custom equal methods by class type so the burden.

In my implementation, I am technically using 2 different EqualsBuilder instances, so I am
not sure if the bug fix would be enough, but, when I walked through the code, you could see
the ignored fields were lost.

If you have an alternative solution without having to use the root implementation to drive
the equals checks, then I am open to it

> EqualsBuilder should be able to call custom equals method for specified class
> -----------------------------------------------------------------------------
>
>                 Key: LANG-1330
>                 URL: https://issues.apache.org/jira/browse/LANG-1330
>             Project: Commons Lang
>          Issue Type: New Feature
>            Reporter: Jason Smiley
>
> As a tester, there are times I want to exclude certain fields (like ID) for my parent
object and its children.
> For example:
> {code}
> class Parent {
> public String id;
> public NormalChild child1;
> public SpecialChild child2;
> //uses ReflectionEqualsBuilder for equals();
> //has custom equalsWithoutID() method;
> }
> class NormalChild extend Child {
> public String name;
> //uses ReflectionEqualsBuilder equals() via inheritence;
> //has custom equalsWithoutID() method;
> }
> class SpecialChild extend Child {
> public String id;
> public String name;
> //uses ReflectionEqualsBuilder for equals() via inheritence
> //has custom equalsWithoutID() method;
> }
> abstract class Child{
> //implementes  equals();
> public abstract boolean equalsWithoutID();
> }
> {code}
> If I am running a reflectionEquals with excluding field "id" on my parent object, the
excludedFields won't be used on my children classes (only excludes fields of parent with name).
I would like to be able to call the custom equalsWithoutID() if its an instance of class Child.
> Currently i need to do a workaround where my equals() checks to see which method I was
using before executing but its not an ideal solution.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message