Package: ParameterExpressionImpl
ParameterExpressionImpl
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ParameterExpressionImpl(Class, String, CriteriaBuilder) |
|
|
|
|
|
||||||||||||||||||||
equals(Object) |
|
|
|
|
|
||||||||||||||||||||
getName() |
|
|
|
|
|
||||||||||||||||||||
getParameterType() |
|
|
|
|
|
||||||||||||||||||||
getPosition() |
|
|
|
|
|
||||||||||||||||||||
hashCode() |
|
|
|
|
|
||||||||||||||||||||
setExpressionToQuery(StringBuilder, CriteriaParameterFiller) |
|
|
|
|
|
||||||||||||||||||||
setNameIfUnnamed(String) |
|
|
|
|
|
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.query.criteria.expressions;
19:
20: import cz.cvut.kbss.jopa.model.query.Parameter;
21: import cz.cvut.kbss.jopa.model.query.criteria.ParameterExpression;
22: import cz.cvut.kbss.jopa.query.criteria.CriteriaParameterFiller;
23: import cz.cvut.kbss.jopa.model.query.criteria.CriteriaBuilder;
24:
25: import java.util.Objects;
26:
27: public class ParameterExpressionImpl<T> extends AbstractExpression<T> implements ParameterExpression<T> {
28: private String name;
29:
30: public ParameterExpressionImpl(Class<T> type, String name, CriteriaBuilder cb) {
31: super(type, cb);
32: this.name = name;
33: }
34:
35: public void setNameIfUnnamed(String name) {
36:• if (this.name == null) {
37: this.name = name;
38: }
39: }
40:
41: @Override
42: public String getName() {
43: return name;
44: }
45:
46: @Override
47: public Integer getPosition() {
48: return null;
49: }
50:
51: @Override
52: public Class<T> getParameterType() {
53: return type;
54: }
55:
56:
57: @Override
58: public void setExpressionToQuery(StringBuilder query, CriteriaParameterFiller parameterFiller) {
59: query.append(parameterFiller.registerParameter(this));
60: }
61:
62: @Override
63: public boolean equals(Object o) {
64:• if (this == o) {
65: return true;
66: }
67:• if (o == null || !Parameter.class.isAssignableFrom(o.getClass())) {
68: return false;
69: }
70: Parameter<?> that = (Parameter<?>) o;
71: return Objects.equals(getName(), that.getName());
72: }
73:
74: @Override
75: public int hashCode() {
76: return Objects.hash(getName(), getPosition());
77: }
78: }