1 16 package com.blandware.atleap.model.core; 17 18 import com.blandware.atleap.common.util.CompositeID; 19 import com.blandware.atleap.common.util.ConvertUtil; 20 21 import java.io.Serializable ; 22 23 35 public class ApplicationResource extends BaseObject { 36 37 39 42 protected ApplicationResourceID id; 43 44 47 protected byte[] value; 48 49 52 protected Long version; 53 54 56 59 public ApplicationResource() { 60 } 61 62 69 public ApplicationResource(ContentLocale locale, String key, String value) { 70 this.id = new ApplicationResourceID(locale, key); 71 this.value = ConvertUtil.convertToByteArray(value); 72 } 73 74 76 82 public ApplicationResourceID getId() { 83 return id; 84 } 85 86 91 public void setId(ApplicationResourceID id) { 92 this.id = id; 93 } 94 95 101 public Long getVersion() { 102 return version; 103 } 104 105 110 public void setVersion(Long version) { 111 this.version = version; 112 } 113 114 120 public byte[] getValue() { 121 return value; 122 } 123 124 129 public void setValue(byte[] value) { 130 this.value = value; 131 } 132 133 public boolean equals(Object o) { 134 if ( this == o ) { 135 return true; 136 } 137 if ( !(o instanceof ApplicationResource) ) { 138 return false; 139 } 140 141 final ApplicationResource applicationResource = (ApplicationResource) o; 142 143 if ( !id.equals(applicationResource.id) ) { 144 return false; 145 } 146 147 return true; 148 } 149 150 public int hashCode() { 151 return id.hashCode(); 152 } 153 154 164 public static class ApplicationResourceID implements CompositeID, Serializable , Comparable { 165 166 169 protected String key; 170 171 174 protected ContentLocale locale; 175 176 179 public ApplicationResourceID() { 180 } 181 182 188 public ApplicationResourceID(ContentLocale locale, String key) { 189 this.key = key; 190 this.locale = locale; 191 } 192 193 200 public String getKey() { 201 return key; 202 } 203 204 209 public void setKey(String key) { 210 this.key = key; 211 } 212 213 219 public ContentLocale getLocale() { 220 return locale; 221 } 222 223 228 public void setLocale(ContentLocale locale) { 229 this.locale = locale; 230 } 231 232 241 public int compareTo(Object o) { 242 if ( !(o instanceof ApplicationResourceID) ) { 243 throw new ClassCastException ("Cannot compare instance of '" + getClass().getName() + "' to the instance of '" + o.getClass().getName() + "'"); 244 } 245 246 ApplicationResourceID id = (ApplicationResourceID) o; 247 if ( key.equalsIgnoreCase(id.key) ) { 248 return locale.compareTo(id.locale); 249 } else { 250 return key.compareTo(id.key); 251 } 252 } 253 254 public boolean equals(Object o) { 255 if ( this == o ) { 256 return true; 257 } 258 if ( !(o instanceof ApplicationResourceID) ) { 259 return false; 260 } 261 262 final ApplicationResourceID applicationResourceID = (ApplicationResourceID) o; 263 264 if ( !key.equals(applicationResourceID.key) ) { 265 return false; 266 } 267 if ( !locale.equals(applicationResourceID.locale) ) { 268 return false; 269 } 270 271 return true; 272 } 273 274 public int hashCode() { 275 int result; 276 result = key.hashCode(); 277 result = 29 * result + locale.hashCode(); 278 return result; 279 } 280 281 } 282 283 284 } 285 | Popular Tags |