Skip to contentMethod: hasContentsProperty(IRI)
1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model.metamodel;
19:
20: import cz.cvut.kbss.jopa.model.IRI;
21: import cz.cvut.kbss.jopa.model.annotations.SequenceType;
22: import cz.cvut.kbss.jopa.oom.converter.ConverterWrapper;
23:
24: import java.util.List;
25:
26: public class ListAttributeImpl<X, V> extends AbstractPluralAttribute<X, List<V>, V>
27: implements ListAttribute<X, V> {
28:
29: private final IRI listClass;
30:
31: private final IRI hasNextProperty;
32:
33: private final IRI hasContentsProperty;
34:
35: private final SequenceType owlSequenceType;
36:
37: ListAttributeImpl(ListAttributeBuilder<X, V> builder) {
38: super(builder);
39: this.listClass = builder.listClass;
40: this.hasNextProperty = builder.hasNextProperty;
41: this.hasContentsProperty = builder.hasContentsProperty;
42: this.owlSequenceType = builder.owlSequenceType;
43: }
44:
45: @Override
46: public CollectionType getCollectionType() {
47: return CollectionType.LIST;
48: }
49:
50: @Override
51: public IRI getListClassIRI() {
52: return listClass;
53: }
54:
55: @Override
56: public IRI getHasNextPropertyIRI() {
57: return hasNextProperty;
58: }
59:
60: @Override
61: public IRI getHasContentsPropertyIRI() {
62: return hasContentsProperty;
63: }
64:
65: @Override
66: public SequenceType getSequenceType() {
67: return owlSequenceType;
68: }
69:
70: @Override
71: public boolean isRDFCollection() {
72: return false;
73: }
74:
75: @Override
76: public String toString() {
77: return "ListAttribute[" + getName() + "]";
78: }
79:
80: static ListAttributeBuilder builder(PropertyAttributes config) {
81: return new ListAttributeBuilder().collectionType(List.class).config(config);
82: }
83:
84: static class ListAttributeBuilder<X, V> extends PluralAttributeBuilder<X, List<V>, V> {
85: private IRI listClass;
86: private IRI hasNextProperty;
87: private IRI hasContentsProperty;
88: private SequenceType owlSequenceType;
89:
90: @Override
91: public ListAttributeBuilder<X, V> config(PropertyAttributes config) {
92: super.config(config);
93: return this;
94: }
95:
96: @Override
97: public ListAttributeBuilder<X, V> collectionType(Class<List<V>> collectionType) {
98: super.collectionType(collectionType);
99: return this;
100: }
101:
102: @Override
103: public ListAttributeBuilder<X, V> propertyInfo(PropertyInfo propertyInfo) {
104: super.propertyInfo(propertyInfo);
105: return this;
106: }
107:
108: @Override
109: public ListAttributeBuilder<X, V> declaringType(ManagedType<X> declaringType) {
110: super.declaringType(declaringType);
111: return this;
112: }
113:
114: @Override
115: public ListAttributeBuilder<X, V> inferred(boolean inferred) {
116: super.inferred(inferred);
117: return this;
118: }
119:
120: @Override
121: public ListAttributeBuilder<X, V> includeExplicit(boolean includeExplicit) {
122: super.includeExplicit(includeExplicit);
123: return this;
124: }
125:
126: @Override
127: public ListAttributeBuilder<X, V> converter(ConverterWrapper converter) {
128: super.converter(converter);
129: return this;
130: }
131:
132: public ListAttributeBuilder<X, V> owlListClass(IRI owlListClass) {
133: this.listClass = owlListClass;
134: return this;
135: }
136:
137: public ListAttributeBuilder<X, V> hasNextProperty(IRI hasNextProperty) {
138: this.hasNextProperty = hasNextProperty;
139: return this;
140: }
141:
142: public ListAttributeBuilder<X, V> hasContentsProperty(IRI hasContentsProperty) {
143: this.hasContentsProperty = hasContentsProperty;
144: return this;
145: }
146:
147: public ListAttributeBuilder<X, V> sequenceType(SequenceType sequenceType) {
148: this.owlSequenceType = sequenceType;
149: return this;
150: }
151:
152: @Override
153: public ListAttributeImpl<X, V> build() {
154: final ListAttributeImpl<X, V> result = new ListAttributeImpl<>(this);
155: mappingValidator.validateAttributeMapping(result);
156: return result;
157: }
158: }
159: }