Skip to content

Method: includeExplicit(boolean)

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