01: /*
02: * Copyright (C) 2004 TiongHiang Lee
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Email: thlee@onemindsoft.org
19: */
20:
21: package org.onemind.swingweb.resource;
22:
23: /**
24: * Abstract impl of resource
25: * @author TiongHiang Lee (thlee@onemindsoft.org)
26: */
27: public abstract class AbstractResource implements Resource {
28:
29: /** the type **/
30: private final String _type;
31:
32: private final String _id;
33:
34: private final Object _obj;
35:
36: /**
37: * Constructor
38: * @param resourceType
39: */
40: public AbstractResource(String id, String resourceType, Object obj) {
41: _id = id;
42: _type = resourceType;
43: _obj = obj;
44: }
45:
46: public String getId() {
47: return _id;
48: }
49:
50: /**
51: * {@inheritDoc}
52: */
53: public final Object getResourceObject() {
54: return _obj;
55: }
56:
57: /**
58: * {@inheritDoc}
59: */
60: public final String getType() {
61: return _type;
62: }
63:
64: /**
65: * {@inheritDoc}
66: */
67: public int hashCode() {
68: return getResourceObject().hashCode();
69: }
70:
71: /**
72: * {@inheritDoc}
73: */
74: public boolean equals(Object obj) {
75: if (obj instanceof Resource) {
76: return getResourceObject().equals(
77: ((Resource) obj).getResourceObject());
78: }
79: return super.equals(obj);
80: }
81: }
|