1 package net.sf.invicta.type; 2 3 import net.sf.invicta.api.DefinedProperty; 4 5 8 public class BasicDefinedProperty { 9 protected String type; 10 protected String name; 11 protected String valueTemplate = null; 12 protected String defaultValue = null; 13 protected String description; 14 15 19 public BasicDefinedProperty() { 20 21 } 22 23 26 public BasicDefinedProperty(String name, String type, String defaultValue, 27 String valueTemplate, String description) { 28 this.name = name; 29 this.type = type; 30 this.valueTemplate = valueTemplate; 31 this.defaultValue = defaultValue; 32 this.description = description; 33 } 34 35 38 public BasicDefinedProperty(BasicDefinedProperty other) { 39 this.name = other.getName(); 40 this.type = other.getType(); 41 this.valueTemplate = other.getValueTemplate(); 42 this.defaultValue = other.getDefaultValue(); 43 this.description = other.getDescription(); 44 } 45 46 49 public void checkRequiredAttributes() throws InvictaTypeException { 50 if ((this.defaultValue == null) && 51 (this.isLocalType() || this.isGeneralType())) 52 throw InvictaTypeException.missingPropertyAttribute(name, "defaultValue"); 53 } 54 55 59 public String getName() { 60 return name; 61 } 62 63 67 public String getType() { 68 return type; 69 } 70 71 75 public void setName(String name) { 76 this.name = name; 77 } 78 79 83 public void setType(String type) { 84 this.type = type; 85 } 86 87 91 public boolean isGeneralType() { 92 return this.type.equalsIgnoreCase(DefinedProperty.TYPE_GENERAL); 93 } 94 95 99 public boolean isComponentType() { 100 return this.type.equalsIgnoreCase(DefinedProperty.TYPE_COMPONENT); 101 } 102 103 107 public boolean isProjectType() { 108 return this.type.equalsIgnoreCase(DefinedProperty.TYPE_PROJECT); 109 } 110 111 115 public boolean isLocalType() { 116 return this.type.equalsIgnoreCase(DefinedProperty.TYPE_LOCAL); 117 } 118 122 public String getValueTemplate() { 123 return valueTemplate; 124 } 125 126 130 public void setValueTemplate(String value) { 131 this.valueTemplate = value; 132 } 133 134 135 139 public String getDefaultValue() { 140 return defaultValue; 141 } 142 143 147 public void setDefaultValue(String defaultValue) { 148 this.defaultValue = defaultValue; 149 } 150 151 154 public boolean equals(BasicDefinedProperty other) { 155 156 return equals(this.type, other.getType()) && 157 equals(this.name, other.getName()) && 158 equals(this.valueTemplate, other.getValueTemplate()) && 159 equals(this.defaultValue, other.getDefaultValue()); 160 } 161 162 165 private boolean equals(Object o1, Object o2) { 166 if ((o1 == null) && (o2 == null)) 167 return true; 168 if ((o1 == null) || (o2 == null)) 169 return false; 170 return o1.equals(o2); 171 } 172 173 176 public String getDescription() { 177 return description; 178 } 179 180 183 public void setDescription(String description) { 184 this.description = description; 185 } 186 187 } 188 | Popular Tags |