commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andres Joy (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LANG-1309) Should EqualsBuilder.reflectionEquals return false if both values of a field is null?
Date Thu, 05 Jan 2017 15:31:58 GMT

     [ https://issues.apache.org/jira/browse/LANG-1309?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Andres Joy updated LANG-1309:
-----------------------------
    Description: 
EqualsBuilder.reflectionEquals return false if both values of the two objects on a field is
null. Is this behavior intended? 

Consider the following example:

{code}class Person {

  String name;
  int age;
  String phone = null;
  ...
}{code}

And a test method:
{code}Person p1 = new Person();
p1.name = "Mike";
p1.age = 30;

Person p2 = new Person();
p2.name = "Mike";
p2.age = 30;

assertTrue(EqualsBuilder.reflectionEquals(p1, p2));{code}

This test won't pass because the assertion will fail. 
Moreover, in this example, the objects we compare are actually equal(morally speaking) and
the check should therefore return true. 

What motivates the current behavior? 

  was:
EqualsBuilder.reflectionEquals return false if both values of the two objects on a field is
null. Is this behavior intended? 

Consider the following example:

{code}class Person {

  String name;
  int age;
  String phone = null;
  ...
}{code}

And a main method:
{code}Person p1 = new Person();
p1.name = "Mike";
p1.age = 30;

Person p2 = new Person();
p2.name = "Mike";
p2.age = 30;

assertTrue(EqualsBuilder.reflectionEquals(p1, p2));{code}

This test won't pass because the assertion will fail. 
Moreover, in this example, the objects we compare are actually equal(morally speaking) and
the check should therefore return true. 

What motivates the current behavior? 


> Should EqualsBuilder.reflectionEquals return false if both values of a field is null?
> -------------------------------------------------------------------------------------
>
>                 Key: LANG-1309
>                 URL: https://issues.apache.org/jira/browse/LANG-1309
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Andres Joy
>            Priority: Minor
>
> EqualsBuilder.reflectionEquals return false if both values of the two objects on a field
is null. Is this behavior intended? 
> Consider the following example:
> {code}class Person {
>   String name;
>   int age;
>   String phone = null;
>   ...
> }{code}
> And a test method:
> {code}Person p1 = new Person();
> p1.name = "Mike";
> p1.age = 30;
> Person p2 = new Person();
> p2.name = "Mike";
> p2.age = 30;
> assertTrue(EqualsBuilder.reflectionEquals(p1, p2));{code}
> This test won't pass because the assertion will fail. 
> Moreover, in this example, the objects we compare are actually equal(morally speaking)
and the check should therefore return true. 
> What motivates the current behavior? 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message