Simplify equals() call on nullable variable and a constant in java.desktop

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P5
    • 18
    • Affects Version/s: 17
    • Component/s: client-libs
    • None
    • b19

      Flipping arguments of 'equals' method, allows simplifying boolean expressions: now we can remove redundant null check before.
      Example:

                  String parent = dir.getParent();
                  if (parent != null && parent.equals("/net")) {
                      return true;
                  }

      Can be simplified to:
                  String parent = dir.getParent();
                  if ("/net".equals(parent)) {
                      return true;
                  }

            Assignee:
            Andrey Turbanov
            Reporter:
            Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: