001: /*
002: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.romaframework.module.admin.domain;
018:
019: import java.io.Serializable;
020:
021: import org.romaframework.aspect.core.annotation.AnnotationConstants;
022: import org.romaframework.aspect.core.annotation.CoreClass;
023: import org.romaframework.aspect.view.annotation.ViewField;
024: import org.romaframework.module.admin.InfoHelper;
025:
026: @CoreClass(orderFields="category text value")
027: public class Info implements Serializable, Cloneable {
028:
029: @ViewField(visible=AnnotationConstants.FALSE)
030: protected InfoCategory category;
031:
032: protected String text;
033: protected Integer value;
034:
035: public Info() {
036: }
037:
038: public Info(String iCategoryName, String iText) {
039: this (iCategoryName, iText, 0);
040: }
041:
042: public Info(String iCategoryName, String iText, Integer iValue) {
043: this (InfoHelper.getInstance().getInfoCategory(iCategoryName),
044: iText, iValue);
045: }
046:
047: public Info(InfoCategory iType, String iText) {
048: this (iType, iText, 0);
049: }
050:
051: public Info(InfoCategory iType, String iText, Integer iValue) {
052: category = iType;
053: text = iText;
054: value = iValue;
055: }
056:
057: @Override
058: public Object clone() throws CloneNotSupportedException {
059: Info cloned = (Info) super .clone();
060: cloned.value = new Integer(value);
061: return cloned;
062: }
063:
064: @Override
065: public boolean equals(Object obj) {
066: if (!(obj instanceof Info))
067: return false;
068:
069: Info other = (Info) obj;
070: return category.equals(other.category)
071: && text.equals(other.text);
072: }
073:
074: @Override
075: public int hashCode() {
076: if (category != null)
077: return category.hashCode() + text.hashCode();
078: return 0;
079: }
080:
081: public InfoCategory getCategory() {
082: return category;
083: }
084:
085: public void setCategory(InfoCategory type) {
086: this .category = type;
087: }
088:
089: public String getText() {
090: return text;
091: }
092:
093: public void setText(String iText) {
094: this .text = iText;
095: }
096:
097: public Integer getValue() {
098: return value;
099: }
100:
101: public void setValue(Integer iValue) {
102: this .value = iValue;
103: }
104:
105: @Override
106: public String toString() {
107: return text;
108: }
109: }
|