Add a simple Binding query language
[mdsal.git] / binding / mdsal-binding-api / src / main / java / org / opendaylight / mdsal / binding / api / query / ComparableMatchBuilder.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.api.query;
9
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.yang.binding.DataObject;
13
14 /**
15  * Builder for a match of a leaf value which define a total ordering by implementing the {@link Comparable} interface.
16  *
17  * <p>
18  * Note that value comparison is preconditioned on target leaf existence. If the leaf does not exist any total ordering
19  * checks will not match it -- thus a non-existent leaf does not match {@link #greaterThan(Comparable)} and at the same
20  * time it does not match {@link #lessThanOrEqual(Comparable)}.
21  *
22  * @param <T> query result type
23  * @param <V> value type
24  */
25 @Beta
26 public interface ComparableMatchBuilder<T extends DataObject, V extends Comparable<V>> extends ValueMatchBuilder<T, V> {
27     /**
28      * Match if the leaf exists and its value is less than the specified value.
29      *
30      * @param value value to check against
31      * @return A ValueMatch
32      * @throws NullPointerException if value is null
33      */
34     @NonNull ValueMatch<T> lessThan(V value);
35
36     /**
37      * Match if the leaf exists and its value is less than, or equal to, the specified value.
38      *
39      * @param value value to check against
40      * @return A ValueMatch
41      * @throws NullPointerException if value is null
42      */
43     @NonNull ValueMatch<T> lessThanOrEqual(V value);
44
45     /**
46      * Match if the leaf exists and its value is greater than the specified value.
47      *
48      * @param value value to check against
49      * @return A ValueMatch
50      * @throws NullPointerException if value is null
51      */
52     @NonNull ValueMatch<T> greaterThan(V value);
53
54     /**
55      * Match if the leaf exists and its value is greater than, or equal to the specified value.
56      *
57      * @param value value to check against
58      * @return A ValueMatch
59      * @throws NullPointerException if value is null
60      */
61     @NonNull ValueMatch<T> greaterThanOrEqual(V value);
62 }