01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.romaframework.module.admin.domain;
18:
19: import java.io.Serializable;
20:
21: import org.romaframework.module.admin.view.domain.info.InfoSelect;
22: import org.romaframework.module.crud.CRUDHelper;
23:
24: public class GenericValue implements Serializable {
25:
26: protected Info info;
27:
28: protected String value;
29:
30: public GenericValue(Info iType, String iValue) {
31: info = iType;
32: value = iValue;
33: }
34:
35: public void onInfo() {
36: CRUDHelper.show(InfoSelect.class, this , "info");
37: }
38:
39: @Override
40: public boolean equals(Object obj) {
41: GenericValue other = (GenericValue) obj;
42:
43: if (info == null || value == null || other.info == null
44: || other.value == null)
45: return false;
46:
47: if (info.equals(other.info)
48: && value.equalsIgnoreCase(other.value))
49: return true;
50:
51: return false;
52: }
53:
54: @Override
55: public String toString() {
56: StringBuffer buffer = new StringBuffer();
57: if (info != null) {
58: buffer.append(info.getText());
59: buffer.append(": ");
60: }
61: buffer.append(value != null ? value : "");
62: return buffer.toString();
63: }
64:
65: @Override
66: public int hashCode() {
67: if (info != null)
68: return info.hashCode();
69: else
70: return 0;
71: }
72:
73: public Info getInfo() {
74: return info;
75: }
76:
77: public void setInfo(Info type) {
78: this .info = type;
79: }
80:
81: public String getValue() {
82: return value;
83: }
84:
85: public void setValue(String value) {
86: this.value = value;
87: }
88: }
|