Skip to content

Package: SingularAttributeImpl$SingularAttributeBuilder

SingularAttributeImpl$SingularAttributeBuilder

nameinstructionbranchcomplexitylinemethod
SingularAttributeImpl.SingularAttributeBuilder()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
attributeType(Attribute.PersistentAttributeType)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
build()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
cascadeTypes(CascadeType[])
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
constraints(ParticipationConstraint[])
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
declaringType(ManagedType)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
fetchType(FetchType)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
field(Field)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
identifier(boolean)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
includeExplicit(boolean)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
inferred(boolean)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
iri(IRI)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
name(String)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
nonEmpty(boolean)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
readOnly(boolean)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
type(Type)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2016 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;
16:
17: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
18: import cz.cvut.kbss.jopa.model.annotations.FetchType;
19: import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
20: import cz.cvut.kbss.jopa.model.metamodel.ManagedType;
21: import cz.cvut.kbss.jopa.model.metamodel.SingularAttribute;
22: import cz.cvut.kbss.jopa.model.metamodel.Type;
23:
24: import java.lang.reflect.Field;
25: import java.lang.reflect.Member;
26:
27: public class SingularAttributeImpl<X, T> implements SingularAttribute<X, T> {
28:
29: private final boolean id;
30:
31: private final String name;
32:
33: private final Type<T> type;
34:
35: private final Field field;
36:
37: private final ManagedType<X> declaringType;
38:
39: private final PersistentAttributeType attributeType;
40:
41: private final IRI iri;
42:
43: private final CascadeType[] cascadeTypes;
44:
45: private final FetchType fetchType;
46:
47: private final boolean inferred;
48:
49: private final boolean includeExplicit;
50:
51: private final boolean readOnly;
52:
53: private final boolean nonEmpty;
54:
55: private ParticipationConstraint[] constraints;
56:
57: private SingularAttributeImpl(SingularAttributeBuilder<X, T> builder) {
58: this.id = builder.id;
59: this.name = builder.name;
60: this.type = builder.type;
61: this.field = builder.field;
62: this.declaringType = builder.declaringType;
63: this.attributeType = builder.attributeType;
64: this.iri = builder.iri;
65: this.cascadeTypes = builder.cascadeTypes;
66: this.fetchType = builder.fetchType;
67: this.inferred = builder.inferred;
68: this.includeExplicit = builder.includeExplicit;
69: this.readOnly = builder.readOnly;
70: this.constraints = builder.constraints;
71: this.nonEmpty = builder.nonEmpty;
72: }
73:
74: @Override
75: public Type<T> getType() {
76: return type;
77: }
78:
79: @Override
80: public boolean isId() {
81: return id;
82: }
83:
84: @Override
85: public boolean isNonEmpty() {
86: return nonEmpty;
87: }
88:
89: @Override
90: public boolean isVersion() {
91: throw new UnsupportedOperationException();
92: }
93:
94: @Override
95: public ManagedType<X> getDeclaringType() {
96: return declaringType;
97: }
98:
99: @Override
100: public Member getJavaMember() {
101: return field;
102: }
103:
104: @Override
105: public Class<T> getJavaType() {
106: return type.getJavaType();
107: }
108:
109: @Override
110: public String getName() {
111: return name;
112: }
113:
114: @Override
115: public PersistentAttributeType getPersistentAttributeType() {
116: return attributeType;
117: }
118:
119: @Override
120: public boolean isAssociation() {
121: return getPersistentAttributeType().equals(
122: PersistentAttributeType.OBJECT);
123: }
124:
125: @Override
126: public boolean isCollection() {
127: return false;
128: }
129:
130: @Override
131: public Class<T> getBindableJavaType() {
132: return type.getJavaType();
133: }
134:
135: @Override
136: public cz.cvut.kbss.jopa.model.metamodel.Bindable.BindableType getBindableType() {
137: return BindableType.SINGULAR_ATTRIBUTE;
138: }
139:
140: @Override
141: public Field getJavaField() {
142: return field;
143: }
144:
145: @Override
146: public IRI getIRI() {
147: return iri;
148: }
149:
150: @Override
151: public CascadeType[] getCascadeTypes() {
152: return cascadeTypes;
153: }
154:
155:
156: @Override
157: public FetchType getFetchType() {
158: return fetchType;
159: }
160:
161:
162: @Override
163: public String toString() {
164: return "SingularAttribute[" + name + "]";
165: }
166:
167: @Override
168: public boolean isInferred() {
169: return inferred;
170: }
171:
172: @Override
173: public ParticipationConstraint[] getConstraints() {
174: return constraints;
175: }
176:
177: @Override
178: public boolean includeExplicit() {
179: return includeExplicit;
180: }
181:
182: @Override
183: public boolean isReadOnly() {
184: return readOnly;
185: }
186:
187: public static SingularAttributeBuilder iri(IRI iri) {
188: return new SingularAttributeBuilder().iri(iri);
189: }
190:
191: public static final class SingularAttributeBuilder<X, T> {
192: private boolean id;
193: private String name;
194: private Type<T> type;
195: private Field field;
196: private ManagedType<X> declaringType;
197: private PersistentAttributeType attributeType;
198: private IRI iri;
199: private CascadeType[] cascadeTypes;
200: private FetchType fetchType;
201: private boolean inferred;
202: private boolean includeExplicit;
203: private boolean readOnly;
204: private boolean nonEmpty = false;
205: private ParticipationConstraint[] constraints;
206:
207: public SingularAttributeBuilder identifier(boolean isId) {
208: this.id = isId;
209: return this;
210: }
211:
212: public SingularAttributeBuilder name(String name) {
213: this.name = name;
214: return this;
215: }
216:
217: public SingularAttributeBuilder type(Type<T> type) {
218: this.type = type;
219: return this;
220: }
221:
222: public SingularAttributeBuilder field(Field field) {
223: this.field = field;
224: return this;
225: }
226:
227: public SingularAttributeBuilder declaringType(ManagedType<X> declaringType) {
228: this.declaringType = declaringType;
229: return this;
230: }
231:
232: public SingularAttributeBuilder attributeType(PersistentAttributeType attributeType) {
233: this.attributeType = attributeType;
234: return this;
235: }
236:
237: public SingularAttributeBuilder iri(IRI iri) {
238: this.iri = iri;
239: return this;
240: }
241:
242: public SingularAttributeBuilder<X, T> cascadeTypes(CascadeType[] cascadeTypes) {
243: this.cascadeTypes = cascadeTypes;
244: return this;
245: }
246:
247: public SingularAttributeBuilder<X, T> fetchType(FetchType fetchType) {
248: this.fetchType = fetchType;
249: return this;
250: }
251:
252: public SingularAttributeBuilder<X, T> inferred(boolean inferred) {
253: this.inferred = inferred;
254: return this;
255: }
256:
257: public SingularAttributeBuilder<X, T> includeExplicit(boolean includeExplicit) {
258: this.includeExplicit = includeExplicit;
259: return this;
260: }
261:
262: public SingularAttributeBuilder<X, T> readOnly(boolean readOnly) {
263: this.readOnly = readOnly;
264: return this;
265: }
266:
267: public SingularAttributeBuilder<X, T> constraints(ParticipationConstraint[] constraints) {
268: this.constraints = constraints;
269: return this;
270: }
271:
272: public SingularAttributeBuilder<X, T> nonEmpty(boolean nonEmpty) {
273: this.nonEmpty = nonEmpty;
274: return this;
275: }
276:
277: public SingularAttribute<X, T> build() {
278: return new SingularAttributeImpl<>(this);
279: }
280: }
281: }