1 17 18 package org.apache.lenya.ac.impl; 19 20 import org.apache.lenya.ac.Item; 21 22 27 public abstract class AbstractItem implements Item { 28 29 private String id; 30 private String description = ""; 31 private String name = ""; 32 33 36 public AbstractItem() { 37 } 38 39 43 protected void setId(String string) { 44 assert isValidId(string); 45 id = string; 46 } 47 48 52 public String getId() { 53 return id; 54 } 55 56 60 public String getDescription() { 61 return description; 62 } 63 64 68 public void setDescription(String description) { 69 assert description != null; 70 this.description = description; 71 } 72 73 76 public String toString() { 77 return getId(); 78 79 } 80 81 86 public String getName() { 87 return name; 88 } 89 90 95 public void setName(String name) { 96 assert name != null; 97 this.name = name; 98 } 99 100 105 public static boolean isValidId(String id) { 106 return id != null && id.matches("\\w+"); 107 } 108 109 112 public boolean equals(Object otherObject) { 113 boolean equals = false; 114 115 if (getClass().isInstance(otherObject)) { 116 AbstractItem otherManageable = (AbstractItem) otherObject; 117 equals = getId().equals(otherManageable.getId()); 118 } 119 120 return equals; 121 } 122 123 126 public int hashCode() { 127 return getId().hashCode(); 128 } 129 130 } | Popular Tags |