Skip to content

Package: PluralQueryAttributeImpl

PluralQueryAttributeImpl

nameinstructionbranchcomplexitylinemethod
PluralQueryAttributeImpl(String, boolean, Field, ManagedType, FetchType, ParticipationConstraint[], Type, Class, ConverterWrapper)
M: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getBindableJavaType()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getBindableType()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getCollectionType()
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%
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%
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%
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%

Coverage

1: /**
2: * Copyright (C) 2022 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.model.annotations.FetchType;
18: import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
19: import cz.cvut.kbss.jopa.oom.converter.ConverterWrapper;
20: import cz.cvut.kbss.jopa.utils.CollectionFactory;
21:
22: import java.lang.reflect.Field;
23:
24: /**
25: * Plural query attributes can contain multiple values or references, ie. they must be a collection.
26: *
27: * @param <X> The represented type that contains the attribute
28: * @param <C> The type of the collection
29: * @param <E> The type of the element inside the collection
30: */
31: public class PluralQueryAttributeImpl<X, C, E> extends AbstractQueryAttribute<X, C>
32: implements PluralQueryAttribute<X, C, E> {
33:
34: private final Type<E> elementType;
35:
36: private final Class<C> collectionType;
37:
38: public PluralQueryAttributeImpl(String query, boolean enableReferencingAttributes, Field field, ManagedType<X> declaringType, FetchType fetchType,
39: ParticipationConstraint[] constraints, Type<E> elementType,
40: Class<C> collectionType, ConverterWrapper converter) {
41: super(query, enableReferencingAttributes, field, declaringType, fetchType, constraints, converter);
42: this.elementType = elementType;
43: this.collectionType = collectionType;
44: }
45:
46: @Override
47: public boolean isCollection() {
48: return true;
49: }
50:
51: @Override
52: public Class<E> getBindableJavaType() {
53: return elementType.getJavaType();
54: }
55:
56: @Override
57: public cz.cvut.kbss.jopa.model.metamodel.Bindable.BindableType getBindableType() {
58: return BindableType.PLURAL_ATTRIBUTE;
59: }
60:
61: @Override
62: public cz.cvut.kbss.jopa.model.metamodel.CollectionType getCollectionType() {
63: return CollectionFactory.resolveCollectionType(getJavaType());
64: }
65:
66: @Override
67: public Type<E> getElementType() {
68: return elementType;
69: }
70:
71: @Override
72: public Class<C> getJavaType() {
73: return collectionType;
74: }
75: }