Skip to contentMethod: builder(PropertyAttributes)
1: /**
2: * Copyright (C) 2023 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 java.util.Collection;
18: import java.util.Set;
19:
20: public class CollectionAttributeImpl<X, V> extends AbstractPluralAttribute<X, Collection<V>, V>
21: implements CollectionAttribute<X, V> {
22:
23: private CollectionAttributeImpl(PluralAttributeBuilder<X, Collection<V>, V> builder) {
24: super(builder);
25: }
26:
27: @Override
28: public CollectionType getCollectionType() {
29: return CollectionType.COLLECTION;
30: }
31:
32: @Override
33: public String toString() {
34: return "CollectionAttribute[" + getName() + "]";
35: }
36:
37: public static PluralAttributeBuilder builder(PropertyAttributes config) {
38: return new CollectionAttributeBuilder().collectionType(Set.class).config(config);
39: }
40:
41: public static class CollectionAttributeBuilder<X, V> extends PluralAttributeBuilder<X, Collection<V>, V> {
42:
43: @Override
44: public CollectionAttributeImpl<X, V> build() {
45: final CollectionAttributeImpl<X, V> result = new CollectionAttributeImpl<>(this);
46: mappingValidator.validateAttributeMapping(result);
47: return result;
48: }
49: }
50: }