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