Skip to content

Package: PathImpl

PathImpl

nameinstructionbranchcomplexitylinemethod
PathImpl(Metamodel, AbstractPathExpression, FieldSpecification, CriteriaBuilder)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
resolveBindableJavaType(FieldSpecification)
M: 4 C: 8
67%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 2
100%
M: 0 C: 1
100%
setExpressionToQuery(StringBuilder, CriteriaParameterFiller)
M: 5 C: 17
77%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 4
80%
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) 2022 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.query.criteria;
14:
15: import cz.cvut.kbss.jopa.model.metamodel.Attribute;
16: import cz.cvut.kbss.jopa.model.metamodel.Bindable;
17: import cz.cvut.kbss.jopa.model.metamodel.FieldSpecification;
18: import cz.cvut.kbss.jopa.model.metamodel.Metamodel;
19: import cz.cvut.kbss.jopa.model.query.criteria.Path;
20: import cz.cvut.kbss.jopa.query.criteria.expressions.AbstractPathExpression;
21: import cz.cvut.kbss.jopa.sessions.CriteriaBuilder;
22:
23: public class PathImpl<X> extends AbstractPathExpression<X> implements Path<X> {
24:
25: protected String attributeName;
26: protected FieldSpecification<?, ?> attribute;
27:
28: public PathImpl(Metamodel metamodel, AbstractPathExpression pathSource, FieldSpecification<?, ?> attribute,
29: CriteriaBuilder cb) {
30: super(resolveBindableJavaType(attribute), pathSource, metamodel, cb);
31: this.attribute = attribute;
32: this.attributeName = attribute.getName();
33: }
34:
35: private static <E> Class<E> resolveBindableJavaType(FieldSpecification<?, ?> attribute) {
36:• assert attribute instanceof Bindable;
37: return ((Bindable<E>) attribute).getBindableJavaType();
38: }
39:
40: @Override
41: public void setExpressionToQuery(StringBuilder query, CriteriaParameterFiller parameterFiller) {
42:• if (this.pathSource != null) {
43: this.pathSource.setExpressionToQuery(query, parameterFiller);
44: query.append('.').append(attributeName);
45: } else {
46: query.append(attributeName);
47: }
48: }
49:
50: }