1 16 package org.jahia.utils.xml.betwixt; 17 18 27 public class BaseDescriptor 28 { 29 32 private String name; 33 34 37 private String id; 38 39 43 private static int uniqueId; 44 45 50 public void setName(String name) 51 { 52 this.name = name; 53 } 54 55 60 public String getName() 61 { 62 return name; 63 } 64 65 70 public void setId(String id) 71 { 72 this.id = id; 73 } 74 75 80 public String getId() 81 { 82 if (id == null) 83 { 84 id = Integer.toString(uniqueId++); 85 } 86 87 return id; 88 } 89 90 95 public String toString() 96 { 97 return name; 98 } 99 100 107 public boolean equals(Object o) 108 { 109 if (o == null) 110 { 111 return false; 112 } 113 114 if (getClass() != o.getClass()) 115 { 116 return false; 117 } 118 119 if (getId() != null) 120 { 121 return getId().equals(((BaseDescriptor) o).getId()); 122 } 123 else 124 { 125 return ((BaseDescriptor) o).getId() == null; 126 } 127 } 128 129 135 public int hashCode() 136 { 137 if (getId() != null) 138 { 139 return getId().hashCode(); 140 } 141 else 142 { 143 return super.hashCode(); 144 } 145 } 146 } 147 | Popular Tags |