Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5475

Use Objects.equals instead of writing same logic

    Details

    • Type: Task
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Core 2.3.0
    • Component/s: None
    • Labels:
      None
    • Complexity:
      Low

      Description

      In few places in the code there is duplicated, not needed logic that does an object equality check treating objects as equal if both reference a null.

      For example, Condition class' equals method does it few times:

       if (onsetDate != null ? !onsetDate.equals(condition.onsetDate) : condition.onsetDate != null)
      { return false; }
      

      Code like this can be replaced with the Objects#equals(Object a, Object b)

      It's a small thing, but removing custom code and using something already available is a good practice. These checks are also error prone since detailed comparison is being made together with lots of negations.

        Attachments

          Activity

            People

            • Assignee:
              michal Michal Fotyga
              Reporter:
              michal Michal Fotyga
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: