01: package org.geotools.feature.iso;
02:
03: import org.geotools.resources.Utilities;
04: import org.opengis.feature.Association;
05: import org.opengis.feature.Attribute;
06: import org.opengis.feature.type.AssociationDescriptor;
07: import org.opengis.feature.type.AssociationType;
08: import org.opengis.feature.type.AttributeType;
09: import org.opengis.feature.type.Name;
10: import org.opengis.feature.type.PropertyDescriptor;
11:
12: public class AssociationImpl implements Association {
13:
14: /**
15: * The related attribute.
16: */
17: Attribute related;
18:
19: /**
20: * The descriptor, this can never be null for association.
21: */
22: AssociationDescriptor descriptor;
23:
24: public AssociationImpl(Attribute related,
25: AssociationDescriptor descriptor) {
26: this .related = related;
27: this .descriptor = descriptor;
28: }
29:
30: public AssociationDescriptor getDescriptor() {
31: return descriptor;
32: }
33:
34: public PropertyDescriptor descriptor() {
35: return getDescriptor();
36: }
37:
38: public AssociationType getType() {
39: return (AssociationType) descriptor.type();
40: }
41:
42: public AttributeType getRelatedType() {
43: return getType().getReferenceType();
44: }
45:
46: public Attribute getRelated() {
47: return related;
48: }
49:
50: public void setRelated(Attribute related) {
51: this .related = related;
52: }
53:
54: public Name name() {
55: return getDescriptor().getName();
56: }
57:
58: public boolean equals(Object other) {
59: if (!(other instanceof AssociationImpl)) {
60: return false;
61: }
62:
63: AssociationImpl assoc = (AssociationImpl) other;
64:
65: if (!Utilities.equals(descriptor, assoc.descriptor))
66: return false;
67:
68: if (!Utilities.equals(related, assoc.related))
69: return false;
70:
71: return true;
72: }
73:
74: public int hashCode() {
75: return 37 * (descriptor.hashCode())
76: + (37 * (related == null ? 0 : related.hashCode()));
77:
78: }
79: }
|