File tree Expand file tree Collapse file tree
src/java/org/apache/commons/cli2/option Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,18 +69,29 @@ public boolean equals(final Object thatObj) {
6969 final OptionImpl that = (OptionImpl )thatObj ;
7070
7171 return getId () == that .getId ()
72- && getPreferredName ().equals (that .getPreferredName ())
73- && (getDescription () == that .getDescription ()
74- || getDescription ().equals (that .getDescription ()))
75- && getPrefixes ().equals (that .getPrefixes ())
76- && getTriggers ().equals (that .getTriggers ());
72+ && equals (getPreferredName (),that .getPreferredName ())
73+ && equals (getDescription (),that .getDescription ())
74+ && equals (getPrefixes (),that .getPrefixes ())
75+ && equals (getTriggers (),that .getTriggers ());
7776 }
7877 else {
7978 return false ;
8079 }
8180 }
8281
83- public int hashCode () {
82+ private boolean equals (Object left , Object right ) {
83+ if (left ==null && right ==null ){
84+ return true ;
85+ }
86+ else if (left ==null || right ==null ){
87+ return false ;
88+ }
89+ else {
90+ return left .equals (right );
91+ }
92+ }
93+
94+ public int hashCode () {
8495 int hashCode = getId ();
8596 hashCode = hashCode * 37 + getPreferredName ().hashCode ();
8697 if (getDescription () != null ) {
You can’t perform that action at this time.
0 commit comments