Skip to contentMethod: attributeType(Attribute.PersistentAttributeType)
1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model.metamodel;
16:
17: import cz.cvut.kbss.jopa.model.IRI;
18: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
19: import cz.cvut.kbss.jopa.model.annotations.FetchType;
20: import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
21: import cz.cvut.kbss.jopa.model.annotations.SequenceType;
22:
23: import java.lang.reflect.Field;
24: import java.util.List;
25:
26: public class ListAttributeImpl<X, V> extends PluralAttributeImpl<X, List<V>, V>
27: implements ListAttribute<X, V> {
28:
29: private final IRI owlListClass;
30:
31: private final IRI owlObjectPropertyHasNext;
32:
33: private final IRI owlPropertyHasContents;
34:
35: private final SequenceType owlSequenceType;
36:
37: public ListAttributeImpl(ListAttributeBuilder<X, V> builder) {
38: super(builder);
39: this.owlListClass = builder.owlListClass;
40: this.owlObjectPropertyHasNext = builder.owlObjectPropertyHasNext;
41: this.owlPropertyHasContents = builder.owlPropertyHasContents;
42: this.owlSequenceType = builder.owlSequenceType;
43: }
44:
45: @Override
46: public CollectionType getCollectionType() {
47: return CollectionType.LIST;
48: }
49:
50: @Override
51: public IRI getOWLListClass() {
52: return owlListClass;
53: }
54:
55: @Override
56: public IRI getOWLObjectPropertyHasNextIRI() {
57: return owlObjectPropertyHasNext;
58: }
59:
60: @Override
61: public IRI getOWLPropertyHasContentsIRI() {
62: return owlPropertyHasContents;
63: }
64:
65: @Override
66: public SequenceType getSequenceType() {
67: return owlSequenceType;
68: }
69:
70: @Override
71: public String toString() {
72: return "ListAttribute[" + getName() + "]";
73: }
74:
75: public static ListAttributeBuilder iri(IRI iri) {
76: return new ListAttributeBuilder().collectionType(List.class).iri(iri);
77: }
78:
79: public static class ListAttributeBuilder<X, V> extends PluralAttributeBuilder<X, List<V>, V> {
80: private IRI owlListClass;
81: private IRI owlObjectPropertyHasNext;
82: private IRI owlPropertyHasContents;
83: private SequenceType owlSequenceType;
84:
85: @Override
86: public ListAttributeBuilder elementType(Type<V> elementType) {
87: super.elementType(elementType);
88: return this;
89: }
90:
91: @Override
92: public ListAttributeBuilder collectionType(Class<List<V>> collectionType) {
93: super.collectionType(collectionType);
94: return this;
95: }
96:
97: @Override
98: public ListAttributeBuilder field(Field field) {
99: super.field(field);
100: return this;
101: }
102:
103: @Override
104: public ListAttributeBuilder declaringType(ManagedType<X> declaringType) {
105: super.declaringType(declaringType);
106: return this;
107: }
108:
109: @Override
110: public ListAttributeBuilder attributeType(PersistentAttributeType attributeType) {
111: super.attributeType(attributeType);
112: return this;
113: }
114:
115: @Override
116: public ListAttributeBuilder iri(IRI iri) {
117: super.iri(iri);
118: return this;
119: }
120:
121: @Override
122: public ListAttributeBuilder cascadeTypes(CascadeType[] cascadeTypes) {
123: super.cascadeTypes(cascadeTypes);
124: return this;
125: }
126:
127: @Override
128: public ListAttributeBuilder fetchType(FetchType fetchType) {
129: super.fetchType(fetchType);
130: return this;
131: }
132:
133: @Override
134: public ListAttributeBuilder inferred(boolean inferred) {
135: super.inferred(inferred);
136: return this;
137: }
138:
139: @Override
140: public ListAttributeBuilder includeExplicit(boolean includeExplicit) {
141: super.includeExplicit(includeExplicit);
142: return this;
143: }
144:
145: @Override
146: public ListAttributeBuilder readOnly(boolean readOnly) {
147: super.readOnly(readOnly);
148: return this;
149: }
150:
151: @Override
152: public ListAttributeBuilder participationConstraints(ParticipationConstraint[] constraints) {
153: super.participationConstraints(constraints);
154: return this;
155: }
156:
157: public ListAttributeBuilder owlListClass(IRI owlListClass) {
158: this.owlListClass = owlListClass;
159: return this;
160: }
161:
162: public ListAttributeBuilder hasNextProperty(IRI hasNextProperty) {
163: this.owlObjectPropertyHasNext = hasNextProperty;
164: return this;
165: }
166:
167: public ListAttributeBuilder hasContentsProperty(IRI hasContentsProperty) {
168: this.owlPropertyHasContents = hasContentsProperty;
169: return this;
170: }
171:
172: public ListAttributeBuilder sequenceType(SequenceType sequenceType) {
173: this.owlSequenceType = sequenceType;
174: return this;
175: }
176:
177: @Override
178: public ListAttributeImpl<X, V> build() {
179: return new ListAttributeImpl<>(this);
180: }
181: }
182: }