File tree Expand file tree Collapse file tree
src/main/java/org/apache/commons/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2020import java .io .Serializable ;
2121import java .util .ArrayList ;
2222import java .util .List ;
23+ import java .util .Objects ;
2324
2425/**
2526 * Describes a single command-line option. It maintains information regarding the short-name of the option, the
@@ -461,22 +462,15 @@ public Object clone() {
461462 }
462463
463464 @ Override
464- public boolean equals (final Object o ) {
465- if (this == o ) {
465+ public boolean equals (Object obj ) {
466+ if (this == obj ) {
466467 return true ;
467468 }
468- if (o == null || getClass () != o . getClass ( )) {
469+ if (!( obj instanceof Option )) {
469470 return false ;
470471 }
471-
472- final Option option = (Option ) o ;
473-
474- if ((this .option != null ? !this .option .equals (option .option ) : option .option != null )
475- || (longOption != null ? !longOption .equals (option .longOption ) : option .longOption != null )) {
476- return false ;
477- }
478-
479- return true ;
472+ Option other = (Option ) obj ;
473+ return Objects .equals (longOption , other .longOption ) && Objects .equals (option , other .option );
480474 }
481475
482476 /**
@@ -655,10 +649,7 @@ public boolean hasArgs() {
655649
656650 @ Override
657651 public int hashCode () {
658- int result ;
659- result = option != null ? option .hashCode () : 0 ;
660- result = 31 * result + (longOption != null ? longOption .hashCode () : 0 );
661- return result ;
652+ return Objects .hash (longOption , option );
662653 }
663654
664655 /**
You can’t perform that action at this time.
0 commit comments