intercom-java icon indicating copy to clipboard operation
intercom-java copied to clipboard

Simplify .equals code

Open thewheat opened this issue 6 years ago • 0 comments

Current code utilises the following format to check for object equality in .equals methods e.g.

if (website != null ? !website.equals(company.website) : company.website != null) return false;

This is hard to read and could be simplified

Possible solution:

if (!Objects.equals(website, company.website)) return false;
  • https://docs.oracle.com/javase/7/docs/api/java/util/Objects.html#equals(java.lang.Object,%20java.lang.Object)
  • Requires Java 7
  • Java 6 looks to stop receiving updates at the end of this year https://en.wikipedia.org/wiki/Java_version_history

image

Raised in https://github.com/intercom/intercom-java/pull/183/files#r206175113

Till need to discuss the possibility of adding and enforcing Java 7 minimum version if we were to implement this

thewheat avatar Aug 07 '18 09:08 thewheat