Skip to content

Package: PluralAttributeImpl

PluralAttributeImpl

nameinstructionbranchcomplexitylinemethod
PluralAttributeImpl(PluralAttributeImpl.PluralAttributeBuilder)
M: 4 C: 64
94%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 17
100%
M: 0 C: 1
100%
getBindableJavaType()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getBindableType()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getCascadeTypes()
M: 3 C: 8
73%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
getCollectionType()
M: 18 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getConstraints()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getDeclaringType()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getElementType()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getFetchType()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getIRI()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getJavaField()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getJavaMember()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getJavaType()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getName()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPersistentAttributeType()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
includeExplicit()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
iri(IRI)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isAssociation()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isCollection()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isInferred()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isNonEmpty()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isReadOnly()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.jopa.model;
14:
15: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
16: import cz.cvut.kbss.jopa.model.annotations.FetchType;
17: import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
18: import cz.cvut.kbss.jopa.model.metamodel.ManagedType;
19: import cz.cvut.kbss.jopa.model.metamodel.PluralAttribute;
20: import cz.cvut.kbss.jopa.model.metamodel.Type;
21:
22: import java.lang.reflect.Field;
23: import java.lang.reflect.Member;
24: import java.util.Collection;
25: import java.util.Map;
26:
27: public class PluralAttributeImpl<X, C, E> implements PluralAttribute<X, C, E> {
28:
29: private final String name;
30:
31: private final Type<E> elementType;
32:
33: private final Class<C> collectionType;
34:
35: private final Field member;
36:
37: private final ManagedType<X> declaringType;
38:
39: private final PersistentAttributeType pat;
40:
41: private final IRI iri;
42:
43: private final CascadeType[] cascadeTypes;
44:
45: private final FetchType fetchType;
46:
47: private boolean inferred;
48:
49: private boolean includeExplicit;
50:
51: private boolean readOnly;
52:
53: private boolean nonEmpty;
54:
55: private ParticipationConstraint[] constraints;
56:
57: protected PluralAttributeImpl(PluralAttributeBuilder<X, C, E> builder) {
58: this.elementType = builder.elementType;
59: this.member = builder.field;
60:• assert member != null;
61: this.name = member.getName();
62: this.pat = builder.attributeType;
63: this.collectionType = builder.collectionType;
64: this.declaringType = builder.declaringType;
65: this.iri = builder.iri;
66: this.cascadeTypes = builder.cascadeTypes;
67: this.fetchType = builder.fetchType;
68: this.inferred = builder.inferred;
69: this.includeExplicit = builder.includeExplicit;
70: this.readOnly = builder.readOnly;
71: this.nonEmpty = builder.nonEmpty;
72: this.constraints = builder.constraints;
73: }
74:
75: @Override
76: public ManagedType<X> getDeclaringType() {
77: return declaringType;
78: }
79:
80: @Override
81: public Member getJavaMember() {
82: return member;
83: }
84:
85: @Override
86: public String getName() {
87: return name;
88: }
89:
90: @Override
91: public cz.cvut.kbss.jopa.model.metamodel.Attribute.PersistentAttributeType getPersistentAttributeType() {
92: return pat;
93: }
94:
95: @Override
96: public boolean isAssociation() {
97: return getPersistentAttributeType().equals(
98: PersistentAttributeType.OBJECT);
99: }
100:
101: @Override
102: public boolean isCollection() {
103: return true;
104: }
105:
106: @Override
107: public Class<E> getBindableJavaType() {
108: return elementType.getJavaType();
109: }
110:
111: @Override
112: public cz.cvut.kbss.jopa.model.metamodel.Bindable.BindableType getBindableType() {
113: return BindableType.PLURAL_ATTRIBUTE;
114: }
115:
116: @Override
117: public cz.cvut.kbss.jopa.model.metamodel.PluralAttribute.CollectionType getCollectionType() {
118:• if (getJavaType().isAssignableFrom(Collection.class)) {
119: return CollectionType.COLLECTION;
120:• } else if (getJavaType().isAssignableFrom(Map.class)) {
121: return CollectionType.MAP;
122: } else {
123: throw new IllegalArgumentException();
124: }
125: }
126:
127: @Override
128: public Type<E> getElementType() {
129: return elementType;
130: }
131:
132: @Override
133: public Class<C> getJavaType() {
134: return collectionType;
135: }
136:
137: @Override
138: public Field getJavaField() {
139: return member;
140: }
141:
142: @Override
143: public IRI getIRI() {
144: return iri;
145: }
146:
147: @Override
148: public CascadeType[] getCascadeTypes() {
149:• if (getPersistentAttributeType().equals(PersistentAttributeType.OBJECT)) {
150: return cascadeTypes;
151: }
152:
153: return cascadeTypes;
154: }
155:
156: @Override
157: public FetchType getFetchType() {
158: return fetchType;
159: }
160:
161: @Override
162: public boolean isInferred() {
163: return inferred;
164: }
165:
166: @Override
167: public boolean includeExplicit() {
168: return includeExplicit;
169: }
170:
171: @Override
172: public boolean isReadOnly() {
173: return readOnly;
174: }
175:
176: @Override
177: public boolean isNonEmpty() {
178: return nonEmpty;
179: }
180:
181: @Override
182: public ParticipationConstraint[] getConstraints() {
183: return constraints;
184: }
185:
186: public static PluralAttributeBuilder iri(IRI iri) {
187: return new PluralAttributeBuilder().iri(iri);
188: }
189:
190:
191: public static class PluralAttributeBuilder<X, C, E> {
192: private Type<E> elementType;
193: private Class<C> collectionType;
194: private Field field;
195: private ManagedType<X> declaringType;
196: private PersistentAttributeType attributeType;
197: private IRI iri;
198: private CascadeType[] cascadeTypes;
199: private FetchType fetchType;
200: private boolean inferred;
201: private boolean includeExplicit;
202: private boolean readOnly;
203: private boolean nonEmpty;
204: private ParticipationConstraint[] constraints;
205:
206: public PluralAttributeBuilder elementType(Type<E> elementType) {
207: this.elementType = elementType;
208: return this;
209: }
210:
211: public PluralAttributeBuilder collectionType(Class<C> collectionType) {
212: this.collectionType = collectionType;
213: return this;
214: }
215:
216: public PluralAttributeBuilder field(Field field) {
217: this.field = field;
218: return this;
219: }
220:
221: public PluralAttributeBuilder declaringType(ManagedType<X> declaringType) {
222: this.declaringType = declaringType;
223: return this;
224: }
225:
226: public PluralAttributeBuilder attributeType(PersistentAttributeType attributeType) {
227: this.attributeType = attributeType;
228: return this;
229: }
230:
231: public PluralAttributeBuilder iri(IRI iri) {
232: this.iri = iri;
233: return this;
234: }
235:
236: public PluralAttributeBuilder cascadeTypes(CascadeType[] cascadeTypes) {
237: this.cascadeTypes = cascadeTypes;
238: return this;
239: }
240:
241: public PluralAttributeBuilder fetchType(FetchType fetchType) {
242: this.fetchType = fetchType;
243: return this;
244: }
245:
246: public PluralAttributeBuilder inferred(boolean inferred) {
247: this.inferred = inferred;
248: return this;
249: }
250:
251: public PluralAttributeBuilder includeExplicit(boolean includeExplicit) {
252: this.includeExplicit = includeExplicit;
253: return this;
254: }
255:
256: public PluralAttributeBuilder readOnly(boolean readOnly) {
257: this.readOnly = readOnly;
258: return this;
259: }
260:
261: public PluralAttributeBuilder nonEmpty(boolean nonEmpty) {
262: this.nonEmpty = nonEmpty;
263: return this;
264: }
265:
266: public PluralAttributeBuilder participationConstraints(ParticipationConstraint[] constraints) {
267: this.constraints = constraints;
268: return this;
269: }
270:
271: public PluralAttributeImpl<X, C, E> build() {
272: return new PluralAttributeImpl<>(this);
273: }
274: }
275: }