Skip to content

Package: OrPredicateImpl

OrPredicateImpl

nameinstructionbranchcomplexitylinemethod
OrPredicateImpl()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
OrPredicateImpl(QueryPredicate[])
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getPredicates()
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%
or(QueryPredicate)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
setPredicates(List)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2018, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.commons.model.query.predicate;
14:
15: import com.google.common.collect.Lists;
16: import org.eclipse.kapua.model.query.predicate.OrPredicate;
17: import org.eclipse.kapua.model.query.predicate.QueryPredicate;
18:
19: import javax.validation.constraints.NotNull;
20: import java.util.ArrayList;
21: import java.util.List;
22: import java.util.Objects;
23:
24: /**
25: * {@link OrPredicate} implementation.
26: *
27: * @since 1.0.0
28: */
29: public class OrPredicateImpl implements OrPredicate {
30:
31: private List<QueryPredicate> predicates;
32:
33: /**
34: * Constructor.
35: *
36: * @since 1.0.0
37: */
38: public OrPredicateImpl() {
39: setPredicates(new ArrayList<>());
40: }
41:
42: /**
43: * Constructor which accepts a not {@code null} array of {@link QueryPredicate}s.
44: *
45: * @param predicates the {@link QueryPredicate}s to add.
46: * @throws NullPointerException if the given parameter is {@code null}.
47: * @since 1.0.0
48: */
49: public OrPredicateImpl(@NotNull QueryPredicate... predicates) {
50: Objects.requireNonNull(predicates);
51:
52: setPredicates(Lists.newArrayList(predicates));
53: }
54:
55: @Override
56: public OrPredicateImpl or(@NotNull QueryPredicate predicate) {
57: Objects.requireNonNull(predicates);
58:
59: getPredicates().add(predicate);
60:
61: return this;
62: }
63:
64: @Override
65: public List<QueryPredicate> getPredicates() {
66: return this.predicates;
67: }
68:
69: @Override
70: public void setPredicates(List<QueryPredicate> predicates) {
71: this.predicates = predicates;
72: }
73: }