Skip to contentMethod: iri(IRI)
1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.jopa.model;
14:
15: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
16: import cz.cvut.kbss.jopa.model.annotations.FetchType;
17: import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
18: import cz.cvut.kbss.jopa.model.annotations.SequenceType;
19: import cz.cvut.kbss.jopa.model.metamodel.ListAttribute;
20: import cz.cvut.kbss.jopa.model.metamodel.ManagedType;
21: import cz.cvut.kbss.jopa.model.metamodel.Type;
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: }