Skip to content

Package: PluralAttributeImpl

PluralAttributeImpl

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