1 55 package org.apache.avalon.framework; 56 57 import java.util.Map ; 58 59 111 public abstract class Enum 112 { 113 116 private final String m_name; 117 118 127 protected Enum( final String name ) 128 { 129 this( name, null ); 130 } 131 132 143 protected Enum( final String name, final Map map ) 144 { 145 m_name = name; 146 if( null != map ) 147 { 148 map.put( name, this ); 149 } 150 } 151 152 162 public final boolean equals( final Object other ) 163 { 164 if( null == other ) 165 { 166 return false; 167 } 168 else 169 { 170 return other == this 171 || ( other.getClass().getName().equals( this.getClass().getName() ) 172 && m_name.equals( ( (Enum )other ).m_name ) ); 173 } 174 } 175 176 181 public int hashCode() 182 { 183 return m_name.hashCode(); 184 } 185 186 190 public final String getName() 191 { 192 return m_name; 193 } 194 195 200 public String toString() 201 { 202 return getClass().getName() + "[" + m_name + "]"; 203 } 204 } 205 | Popular Tags |