Skip to content

Package: AbstractQueryAttribute

AbstractQueryAttribute

nameinstructionbranchcomplexitylinemethod
AbstractQueryAttribute(String, boolean, Field, ManagedType, FetchType, ParticipationConstraint[], ConverterWrapper)
M: 0 C: 24
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
enableReferencingAttributes()
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%
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%
getConverter()
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%
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%
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%
getName()
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%
getQuery()
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: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isInferred()
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%
toString()
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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:
21: import java.lang.reflect.Field;
22: import java.lang.reflect.Member;
23:
24: /**
25: * A common class to all attributes defined by a query
26: *
27: * @param <X> The represented type that contains the attribute
28: * @param <Y> The type of the represented attribute
29: */
30: public abstract class AbstractQueryAttribute<X, Y> implements QueryAttribute<X, Y> {
31:
32: /**
33: * Name of the variable which may be used in the query and would be replaced by the identifier of the entity owning
34: * this attribute.
35: */
36: public static final String THIS_PARAMETER = "this";
37:
38: private final String query;
39:
40: private final boolean enableReferencingAttributes;
41:
42: private final Field field;
43:
44: private final ManagedType<X> declaringType;
45:
46: private final FetchType fetchType;
47:
48: private final ParticipationConstraint[] constraints;
49:
50: private final ConverterWrapper converter;
51:
52: public AbstractQueryAttribute(String query, boolean enableReferencingAttributes, Field field,
53: ManagedType<X> declaringType, FetchType fetchType,
54: ParticipationConstraint[] constraints, ConverterWrapper converter) {
55: this.query = query;
56: this.enableReferencingAttributes = enableReferencingAttributes;
57: this.field = field;
58: this.declaringType = declaringType;
59: this.fetchType = fetchType;
60: this.constraints = constraints;
61: this.converter = converter;
62: }
63:
64: @Override
65: public String getQuery() {
66: return query;
67: }
68:
69: @Override
70: public boolean enableReferencingAttributes() {
71: return enableReferencingAttributes;
72: }
73:
74: @Override
75: public Member getJavaMember() {
76: return field;
77: }
78:
79: @Override
80: public ParticipationConstraint[] getConstraints() {
81: return constraints;
82: }
83:
84: @Override
85: public ManagedType<X> getDeclaringType() {
86: return declaringType;
87: }
88:
89: @Override
90: public Field getJavaField() {
91: return field;
92: }
93:
94: @Override
95: public FetchType getFetchType() {
96: return fetchType;
97: }
98:
99: /**
100: * A query based attribute is always inferred.
101: *
102: * @return always {@code true}
103: */
104: @Override
105: public boolean isInferred() {
106: return true;
107: }
108:
109: /**
110: * A query based attribute always includes explicit.
111: *
112: * @return always {@code true}
113: */
114: @Override
115: public boolean includeExplicit() {
116: return true;
117: }
118:
119: @Override
120: public String getName() {
121: return field.getName();
122: }
123:
124: @Override
125: public abstract boolean isCollection();
126:
127: public ConverterWrapper getConverter() {
128: return converter;
129: }
130:
131: @Override
132: public String toString() {
133: return declaringType.getJavaType().getSimpleName() + "." + getName();
134: }
135: }