roxspring    2004/01/29 14:32:33

  Modified:    cli/src/java/org/apache/commons/cli2 Tag:
                        RESEARCH_CLI_2_ROXSPRING OptionImpl.java
  Log:
  Created basic implementation of equals(Object) and hashCode().
  Should probably specialise further in other implementations
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +31 -0     
jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/OptionImpl.java
  
  Index: OptionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/Attic/OptionImpl.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- OptionImpl.java   22 Jan 2004 22:40:51 -0000      1.1.2.2
  +++ OptionImpl.java   29 Jan 2004 22:32:33 -0000      1.1.2.3
  @@ -98,4 +98,35 @@
       public int getId() {
           return id;
       }
  +
  +    /* (non-Javadoc)
  +     * @see java.lang.Object#equals(java.lang.Object)
  +     */
  +    public boolean equals(final Object thatObj) {
  +        if(thatObj instanceof OptionImpl){
  +            final OptionImpl that = (OptionImpl)thatObj;
  +            
  +            return
  +             getId()==that.getId() &&
  +             getPreferredName().equals(that.getPreferredName()) &&
  +             getDescription().equals(that.getDescription()) &&
  +             getPrefixes().equals(that.getPrefixes()) &&
  +             getTriggers().equals(that.getTriggers());
  +        }
  +        else{
  +            return false;
  +        }
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see java.lang.Object#hashCode()
  +     */
  +    public int hashCode() {
  +        int hashCode = getId();
  +        hashCode = hashCode*37+getPreferredName().hashCode();
  +        hashCode = hashCode*37+getDescription().hashCode();
  +        hashCode = hashCode*37+getPrefixes().hashCode();
  +        hashCode = hashCode*37+getTriggers().hashCode();
  +        return hashCode;
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to