Skip to content

Method: isCollection()

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.oom.converter.ConverterWrapper;
21:
22: public class SingularAttributeImpl<X, Y> extends AbstractAttribute<X, Y> implements SingularAttribute<X, Y> {
23:
24: private final Type<Y> type;
25:
26: private SingularAttributeImpl(SingularAttributeBuilder<X, Y> builder) {
27: super(builder);
28: this.type = builder.type;
29: }
30:
31: @Override
32: public Type<Y> getType() {
33: return type;
34: }
35:
36: @Override
37: public boolean isId() {
38: return false;
39: }
40:
41: @Override
42: public boolean isVersion() {
43: throw new UnsupportedOperationException();
44: }
45:
46: @Override
47: public Class<Y> getJavaType() {
48: return type.getJavaType();
49: }
50:
51: @Override
52: public boolean isCollection() {
53: return false;
54: }
55:
56: @Override
57: public Class<Y> getBindableJavaType() {
58: return type.getJavaType();
59: }
60:
61: @Override
62: public BindableType getBindableType() {
63: return BindableType.SINGULAR_ATTRIBUTE;
64: }
65:
66: public static SingularAttributeBuilder builder(PropertyAttributes config) {
67: return new SingularAttributeBuilder().config(config);
68: }
69:
70: public static final class SingularAttributeBuilder<X, Y> extends AbstractAttributeBuilder<X, Y> {
71: private Type<Y> type;
72:
73: @Override
74: public SingularAttributeBuilder<X, Y> config(PropertyAttributes config) {
75: super.config(config);
76: type((Type<Y>) config.getType());
77: return this;
78: }
79:
80: public SingularAttributeBuilder<X, Y> type(Type<Y> type) {
81: this.type = type;
82: return this;
83: }
84:
85: @Override
86: public SingularAttributeBuilder<X, Y> propertyInfo(PropertyInfo propertyInfo) {
87: super.propertyInfo(propertyInfo);
88: return this;
89: }
90:
91: @Override
92: public SingularAttributeBuilder<X, Y> declaringType(ManagedType<X> declaringType) {
93: super.declaringType(declaringType);
94: return this;
95: }
96:
97: @Override
98: public SingularAttributeBuilder<X, Y> inferred(boolean inferred) {
99: super.inferred(inferred);
100: return this;
101: }
102:
103: @Override
104: public SingularAttributeBuilder<X, Y> includeExplicit(boolean includeExplicit) {
105: super.includeExplicit(includeExplicit);
106: return this;
107: }
108:
109: @Override
110: public SingularAttributeBuilder<X, Y> converter(ConverterWrapper converter) {
111: super.converter(converter);
112: return this;
113: }
114:
115: @Override
116: public SingularAttributeImpl<X, Y> build() {
117: final SingularAttributeImpl<X, Y> result = new SingularAttributeImpl<>(this);
118: mappingValidator.validateAttributeMapping(result);
119: return result;
120: }
121: }
122: }