1 19 package org.java.plugin.registry.xml; 20 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 import org.java.plugin.registry.Identity; 24 import org.java.plugin.registry.ManifestProcessingException; 25 26 29 abstract class IdentityImpl implements Identity { 30 33 protected final Log log = LogFactory.getLog(getClass()); 34 35 private final String id; 36 37 protected IdentityImpl(final String anId) 38 throws ManifestProcessingException { 39 id = anId; 40 if ((id == null) || (id.trim().length() == 0)) { 41 throw new ManifestProcessingException( 42 PluginRegistryImpl.PACKAGE_NAME, 43 "manifestElementIdIsBlank"); } 45 } 46 47 50 public String getId() { 51 return id; 52 } 53 54 protected abstract boolean isEqualTo(final Identity idt); 55 56 59 public boolean equals(final Object obj) { 60 if (this == obj) { 61 return true; 62 } 63 if (!(obj instanceof Identity)) { 64 return false; 65 } 66 return isEqualTo((Identity) obj); 67 } 68 69 private int hashCode = -1; 70 71 74 public int hashCode() { 75 if (hashCode == -1) { 76 hashCode = getClass().hashCode() ^ getId().hashCode(); 77 } 78 return hashCode; 79 } 80 } 81 | Popular Tags |