Package: AbstractExpression
AbstractExpression
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AbstractExpression(Class, CriteriaBuilder) |
|
|
|
|
|
||||||||||||||||||||
in(Collection) |
|
|
|
|
|
||||||||||||||||||||
in(Object[]) |
|
|
|
|
|
||||||||||||||||||||
isNegated() |
|
|
|
|
|
||||||||||||||||||||
lambda$in$0(PredicateFactory.In, Object) |
|
|
|
|
|
||||||||||||||||||||
negate() |
|
|
|
|
|
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.criteria.Expression;
21: import cz.cvut.kbss.jopa.model.query.criteria.Predicate;
22: import cz.cvut.kbss.jopa.query.criteria.CriteriaParameterFiller;
23: import cz.cvut.kbss.jopa.query.criteria.SelectionImpl;
24: import cz.cvut.kbss.jopa.model.query.criteria.CriteriaBuilder;
25: import cz.cvut.kbss.jopa.model.query.criteria.PredicateFactory;
26:
27: import java.util.Arrays;
28: import java.util.Collection;
29:
30: /**
31: * Parent of all other types of expressions.
32: * <p>
33: * It offers its children the implementation of methods for IN expression as prescribed by the Expression interface.
34: * Prescribes an abstract method for expressing an expression to string builder representing the query.
35: */
36: public abstract class AbstractExpression<Y> extends SelectionImpl<Y> implements Expression<Y> {
37:
38: protected final CriteriaBuilder cb;
39:
40: protected boolean negated;
41:
42: public AbstractExpression(Class<Y> type, CriteriaBuilder cb) {
43: super(type);
44: this.cb = cb;
45: negated = false;
46: }
47:
48: @Override
49: public Predicate in(Collection<?> values) {
50: PredicateFactory.In<Y> predicate = cb.in(this);
51: values.forEach(v -> predicate.value((Y) v));
52: return predicate;
53: }
54:
55: @Override
56: public Predicate in(Object... values) {
57: return this.in(Arrays.asList(values));
58: }
59:
60: public abstract void setExpressionToQuery(StringBuilder query, CriteriaParameterFiller parameterFiller);
61:
62: public boolean isNegated() {
63: return negated;
64: }
65:
66: public void negate() {
67: this.negated = true;
68: }
69: }
70:
71: