01: /*
02: * Copyright 2006 Le Duc Bao, Ralf Joachim
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * 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, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package org.castor.ddlgen.schemaobject;
17:
18: import org.castor.ddlgen.DDLGenConfiguration;
19:
20: /**
21: * Abstract base class for all schema objects.
22: *
23: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
24: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
25: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
26: * @since 1.1
27: */
28: public abstract class AbstractSchemaObject implements SchemaObject {
29: //--------------------------------------------------------------------------
30:
31: /** Factor for calculation of hash code. */
32: protected static final int HASHFACTOR = 17;
33:
34: /** Configuration of the schema object. */
35: private DDLGenConfiguration _config;
36:
37: /** Name of the schema object. */
38: private String _name;
39:
40: //--------------------------------------------------------------------------
41:
42: /**
43: * {@inheritDoc}
44: */
45: public final void setConfiguration(final DDLGenConfiguration config) {
46: _config = config;
47: }
48:
49: /**
50: * {@inheritDoc}
51: */
52: public final DDLGenConfiguration getConfiguration() {
53: return _config;
54: }
55:
56: /**
57: * {@inheritDoc}
58: */
59: public final void setName(final String name) {
60: _name = name;
61: }
62:
63: /**
64: * {@inheritDoc}
65: */
66: public final String getName() {
67: return _name;
68: }
69:
70: //--------------------------------------------------------------------------
71:
72: /**
73: * Check the 2 given objects for equality by taking into account that one or both of
74: * them may be <code>null</code>.
75: *
76: * @param obj1 First object.
77: * @param obj2 Second object.
78: * @return <code>true</code> if both objects are null or equal as defined by
79: * equals method of object. <code>false</code> if only one of the objects
80: * is null or if they are not equal.
81: */
82: protected static final boolean equals(final Object obj1,
83: final Object obj2) {
84: if ((obj1 == null) && (obj2 == null)) {
85: return true;
86: }
87: if ((obj1 == null) || (obj2 == null)) {
88: return false;
89: }
90: return obj1.equals(obj2);
91: }
92:
93: //--------------------------------------------------------------------------
94: }
|