Skip to content

Method: getKeyType()

1: package de.fhdw.wtf.persistence.meta;
2:
3: /**
4: * A class to represent an association between an owning user type and a object and a hashmap-object.
5: *
6: */
7: public class MapAssociation extends Association {
8:         
9:         /**
10:          * When the association is a map, then the keyType is the type of the map-key, in every other circumstance null.
11:          */
12:         private final Type keyType;
13:         
14:         /**
15:          * Getter of the map-key type of the association.
16:          *
17:          * @return Provides the map-key type of the association or null when no map-key type is set.
18:          */
19:         public Type getKeyType() {
20:                 return this.keyType;
21:         }
22:         
23:         /**
24:          * Constructor for a new association. It should only be calles by the class facade or unit tests because the Ids are
25:          * provided by the database.
26:          *
27:          * @param id
28:          * The Id of the association in the database.
29:          * @param name
30:          * The name of the UnidirectionalAssociation.
31:          * @param owner
32:          * The Owner type of the association.
33:          * @param target
34:          * The target type of the association.
35:          * @param keyType
36:          * The hashmap-key type of the association.
37:          * @param essential
38:          * true if map values can be empty
39:          */
40:         public MapAssociation(final long id,
41:                         final String name,
42:                         final UserType owner,
43:                         final Type target,
44:                         final Type keyType,
45:                         final boolean essential) {
46:                 super(id, name, owner, target, essential, true);
47:                 this.keyType = keyType;
48:         }
49:         
50:         @Override
51:         public boolean isTheSameAs(final java.lang.Object other) {
52:                 if (other instanceof MapAssociation) {
53:                         return super.isTheSameAs(other);
54:                 }
55:                 return false;
56:         }
57: }