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