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: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model.metamodel;
19:
20: import cz.cvut.kbss.jopa.model.annotations.FetchType;
21: import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
22: import cz.cvut.kbss.jopa.oom.converter.ConverterWrapper;
23: import cz.cvut.kbss.jopa.utils.CollectionFactory;
24:
25: import java.lang.reflect.Field;
26:
27: /**
28: * Plural query attributes can contain multiple values or references, ie. they must be a collection.
29: *
30: * @param <X> The represented type that contains the attribute
31: * @param <C> The type of the collection
32: * @param <E> The type of the element inside the collection
33: */
34: public class PluralQueryAttributeImpl<X, C, E> extends AbstractQueryAttribute<X, C>
35: implements PluralQueryAttribute<X, C, E> {
36:
37: private final Type<E> elementType;
38:
39: private final Class<C> collectionType;
40:
41: public PluralQueryAttributeImpl(String query, boolean enableReferencingAttributes, Field field, ManagedType<X> declaringType, FetchType fetchType,
42: ParticipationConstraint[] constraints, Type<E> elementType,
43: Class<C> collectionType, ConverterWrapper converter) {
44: super(query, enableReferencingAttributes, field, declaringType, fetchType, constraints, converter);
45: this.elementType = elementType;
46: this.collectionType = collectionType;
47: }
48:
49: @Override
50: public boolean isCollection() {
51: return true;
52: }
53:
54: @Override
55: public Class<E> getBindableJavaType() {
56: return elementType.getJavaType();
57: }
58:
59: @Override
60: public cz.cvut.kbss.jopa.model.metamodel.Bindable.BindableType getBindableType() {
61: return BindableType.PLURAL_ATTRIBUTE;
62: }
63:
64: @Override
65: public cz.cvut.kbss.jopa.model.metamodel.CollectionType getCollectionType() {
66: return CollectionFactory.resolveCollectionType(getJavaType());
67: }
68:
69: @Override
70: public Type<E> getElementType() {
71: return elementType;
72: }
73:
74: @Override
75: public Class<C> getJavaType() {
76: return collectionType;
77: }
78: }