1 22 package org.jboss.lang; 23 24 31 public abstract class Enum implements java.io.Serializable 32 { 33 protected final transient String name; 34 protected final int ordinal; 35 36 protected Enum(String name, int ordinal) 37 { 38 this.name = name; 39 this.ordinal = ordinal; 40 } 41 public String toString() 42 { 43 return name; 44 } 45 46 public String name() 47 { 48 return name; 49 } 50 51 public int ordinal() 52 { 53 return ordinal; 54 } 55 56 public boolean equals(Object o) 57 { 58 if (o == this) return true; 59 if (o == null) return false; 60 if (!(o instanceof Enum )) return false; 61 if (!o.getClass().equals(this.getClass())) return false; 62 Enum en = (Enum )o; 63 return en.ordinal == this.ordinal; 64 } 65 66 public int hashCode() 67 { 68 return name.hashCode(); 69 } 70 71 } 72 | Popular Tags |