1 50 51 package org.apache.avalon.meta.info; 52 53 import java.io.Serializable ; 54 55 67 public final class EntryDescriptor 68 implements Serializable 69 { 70 73 private final String m_key; 74 75 78 private final String m_classname; 79 80 83 private final boolean m_optional; 84 85 88 private final boolean m_volatile; 89 90 93 private final String m_alias; 94 95 101 public EntryDescriptor( final String key, 102 final String classname ) throws NullPointerException 103 { 104 this( key, classname, false ); 105 } 106 107 114 public EntryDescriptor( final String key, 115 final String classname, 116 final boolean optional ) throws NullPointerException 117 { 118 this( key, classname, optional, false ); 119 } 120 121 129 public EntryDescriptor( final String key, 130 final String classname, 131 final boolean optional, 132 final boolean isVolatile ) throws NullPointerException 133 { 134 this( key, classname, optional, isVolatile, null ); 135 } 136 137 146 public EntryDescriptor( final String key, 147 final String classname, 148 final boolean optional, 149 final boolean isVolatile, 150 final String alias ) throws NullPointerException 151 { 152 if ( null == key ) 153 { 154 throw new NullPointerException ( "key" ); 155 } 156 if ( null == classname ) 157 { 158 throw new NullPointerException ( "classnamei" ); 159 } 160 161 m_key = key; 162 m_classname = classname; 163 m_optional = optional; 164 m_volatile = isVolatile; 165 m_alias = alias; 166 } 167 168 173 public String getKey() 174 { 175 return m_key; 176 } 177 178 185 public String getAlias() 186 { 187 if( m_alias != null ) 188 { 189 return m_alias; 190 } 191 else 192 { 193 return m_key; 194 } 195 } 196 197 202 public String getClassname() 203 { 204 return m_classname; 205 } 206 207 212 public boolean isOptional() 213 { 214 return m_optional; 215 } 216 217 222 public boolean isRequired() 223 { 224 return !isOptional(); 225 } 226 227 232 public boolean isVolatile() 233 { 234 return m_volatile; 235 } 236 237 242 public boolean equals( Object other ) 243 { 244 boolean isEqual = other instanceof EntryDescriptor; 245 246 if ( isEqual ) 247 { 248 EntryDescriptor entry = (EntryDescriptor) other; 249 250 isEqual = isEqual && m_key.equals( entry.m_key ); 251 isEqual = isEqual && m_classname.equals( entry.m_classname ); 252 isEqual = isEqual && m_optional == entry.m_optional; 253 isEqual = isEqual && m_volatile == entry.m_volatile; 254 if ( null == m_alias ) 255 { 256 isEqual = isEqual && null == entry.m_alias; 257 } 258 else 259 { 260 isEqual = isEqual && m_alias.equals( entry.m_alias ); 261 } 262 } 263 264 return isEqual; 265 } 266 267 271 public int hashCode() 272 { 273 int hash = super.hashCode(); 274 hash >>>= 13; 275 hash ^= m_key.hashCode(); 276 hash >>>= 13; 277 hash ^= m_classname.hashCode(); 278 hash >>>= 13; 279 hash ^= ( null != m_alias ) ? m_alias.hashCode() : 0; 280 hash >>>= 13; 281 hash >>>= ( m_volatile ) ? 1 : 3; 282 hash >>>= ( m_optional ) ? 1 : 3; 283 284 return hash; 285 } 286 } 287 | Popular Tags |