Skip to contentMethod: field(Field)
1: /**
2: * Copyright (C) 2019 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.metamodel;
14:
15: import cz.cvut.kbss.jopa.model.IRI;
16: import cz.cvut.kbss.jopa.model.annotations.SequenceType;
17: import cz.cvut.kbss.jopa.oom.converter.ConverterWrapper;
18:
19: import java.lang.reflect.Field;
20: import java.util.List;
21:
22: public class ListAttributeImpl<X, V> extends AbstractPluralAttribute<X, List<V>, V>
23: implements ListAttribute<X, V> {
24:
25: private final IRI owlListClass;
26:
27: private final IRI owlObjectPropertyHasNext;
28:
29: private final IRI owlPropertyHasContents;
30:
31: private final SequenceType owlSequenceType;
32:
33: private ListAttributeImpl(ListAttributeBuilder<X, V> builder) {
34: super(builder);
35: this.owlListClass = builder.owlListClass;
36: this.owlObjectPropertyHasNext = builder.owlObjectPropertyHasNext;
37: this.owlPropertyHasContents = builder.owlPropertyHasContents;
38: this.owlSequenceType = builder.owlSequenceType;
39: }
40:
41: @Override
42: public CollectionType getCollectionType() {
43: return CollectionType.LIST;
44: }
45:
46: @Override
47: public IRI getOWLListClass() {
48: return owlListClass;
49: }
50:
51: @Override
52: public IRI getOWLObjectPropertyHasNextIRI() {
53: return owlObjectPropertyHasNext;
54: }
55:
56: @Override
57: public IRI getOWLPropertyHasContentsIRI() {
58: return owlPropertyHasContents;
59: }
60:
61: @Override
62: public SequenceType getSequenceType() {
63: return owlSequenceType;
64: }
65:
66: @Override
67: public String toString() {
68: return "ListAttribute[" + getName() + "]";
69: }
70:
71: public static ListAttributeBuilder builder(PropertyAttributes config) {
72: return new ListAttributeBuilder().collectionType(List.class).config(config);
73: }
74:
75: public static class ListAttributeBuilder<X, V> extends PluralAttributeBuilder<X, List<V>, V> {
76: private IRI owlListClass;
77: private IRI owlObjectPropertyHasNext;
78: private IRI owlPropertyHasContents;
79: private SequenceType owlSequenceType;
80:
81: @Override
82: public ListAttributeBuilder<X, V> config(PropertyAttributes config) {
83: super.config(config);
84: return this;
85: }
86:
87: @Override
88: public ListAttributeBuilder<X, V> collectionType(Class<List<V>> collectionType) {
89: super.collectionType(collectionType);
90: return this;
91: }
92:
93: @Override
94: public ListAttributeBuilder<X, V> field(Field field) {
95: super.field(field);
96: return this;
97: }
98:
99: @Override
100: public ListAttributeBuilder<X, V> declaringType(ManagedType<X> declaringType) {
101: super.declaringType(declaringType);
102: return this;
103: }
104:
105: @Override
106: public ListAttributeBuilder<X, V> inferred(boolean inferred) {
107: super.inferred(inferred);
108: return this;
109: }
110:
111: @Override
112: public ListAttributeBuilder<X, V> includeExplicit(boolean includeExplicit) {
113: super.includeExplicit(includeExplicit);
114: return this;
115: }
116:
117: @Override
118: public ListAttributeBuilder<X, V> converter(ConverterWrapper converter) {
119: super.converter(converter);
120: return this;
121: }
122:
123: public ListAttributeBuilder<X, V> owlListClass(IRI owlListClass) {
124: this.owlListClass = owlListClass;
125: return this;
126: }
127:
128: public ListAttributeBuilder<X, V> hasNextProperty(IRI hasNextProperty) {
129: this.owlObjectPropertyHasNext = hasNextProperty;
130: return this;
131: }
132:
133: public ListAttributeBuilder<X, V> hasContentsProperty(IRI hasContentsProperty) {
134: this.owlPropertyHasContents = hasContentsProperty;
135: return this;
136: }
137:
138: public ListAttributeBuilder<X, V> sequenceType(SequenceType sequenceType) {
139: this.owlSequenceType = sequenceType;
140: return this;
141: }
142:
143: @Override
144: public ListAttributeImpl<X, V> build() {
145: return new ListAttributeImpl<>(this);
146: }
147: }
148: }