Revert "Add support for selecting exact items from lists"
[mdsal.git] / binding / mdsal-binding-api / src / main / java / org / opendaylight / mdsal / binding / api / query / MatchBuilderPath.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 java.io.Serializable;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.concepts.Mutable;
14 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
15 import org.opendaylight.yangtools.yang.binding.ChildOf;
16 import org.opendaylight.yangtools.yang.binding.ChoiceIn;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.TypeObject;
19 import org.opendaylight.yangtools.yang.common.Empty;
20 import org.opendaylight.yangtools.yang.common.Uint16;
21 import org.opendaylight.yangtools.yang.common.Uint32;
22 import org.opendaylight.yangtools.yang.common.Uint64;
23 import org.opendaylight.yangtools.yang.common.Uint8;
24
25 @Beta
26 public interface MatchBuilderPath<O extends DataObject, T extends DataObject> extends Mutable {
27     /**
28      * Descend match into a child container.
29      *
30      * @param <N> Child container type
31      * @param childClass Child container type class
32      * @return This builder
33      * @throws NullPointerException if childClass is null
34      */
35     <N extends ChildOf<? super T>> @NonNull MatchBuilderPath<O, N> childObject(Class<N> childClass);
36
37     /**
38      * Descend match into a child container in a particular case.
39      *
40      * @param <C> Case type
41      * @param <N> Child container type
42      * @param childClass Child container type class
43      * @return This builder
44      * @throws NullPointerException if any argument is null
45      */
46     <C extends ChoiceIn<? super T> & DataObject, N extends ChildOf<? super C>>
47         @NonNull MatchBuilderPath<O, N> extractChild(Class<C> caseClass, Class<N> childClass);
48
49     /**
50      * Match an {@code empty} leaf's value.
51      *
52      * @param methodRef method reference to the getter method
53      * @return A {@link ValueMatchBuilder}
54      * @throws NullPointerException if methodRef is null
55      */
56     @NonNull ValueMatchBuilder<O, Empty> leaf(EmptyLeafReference<T> methodRef);
57
58     /**
59      * Match an {@code string} leaf's value.
60      *
61      * @param methodRef method reference to the getter method
62      * @return A {@link StringMatchBuilder}
63      * @throws NullPointerException if methodRef is null
64      */
65     @NonNull StringMatchBuilder<O> leaf(StringLeafReference<T> methodRef);
66
67     /**
68      * Match an {@code int8} leaf's value.
69      *
70      * @param methodRef method reference to the getter method
71      * @return A {@link ComparableMatchBuilder}
72      * @throws NullPointerException if methodRef is null
73      */
74     @NonNull ComparableMatchBuilder<O, Byte> leaf(Int8LeafReference<T> methodRef);
75
76     /**
77      * Match an {@code int16} leaf's value.
78      *
79      * @param methodRef method reference to the getter method
80      * @return A {@link ComparableMatchBuilder}
81      * @throws NullPointerException if methodRef is null
82      */
83     @NonNull ComparableMatchBuilder<O, Short> leaf(Int16LeafReference<T> methodRef);
84
85     /**
86      * Match an {@code int32} leaf's value.
87      *
88      * @param methodRef method reference to the getter method
89      * @return A {@link ComparableMatchBuilder}
90      * @throws NullPointerException if methodRef is null
91      */
92     @NonNull ComparableMatchBuilder<O, Integer> leaf(Int32LeafReference<T> methodRef);
93
94     /**
95      * Match an {@code int64} leaf's value.
96      *
97      * @param methodRef method reference to the getter method
98      * @return A {@link ComparableMatchBuilder}
99      * @throws NullPointerException if methodRef is null
100      */
101     @NonNull ComparableMatchBuilder<O, Long> leaf(Int64LeafReference<T> methodRef);
102
103     /**
104      * Match an {@code uint8} leaf's value.
105      *
106      * @param methodRef method reference to the getter method
107      * @return A {@link ComparableMatchBuilder}
108      * @throws NullPointerException if methodRef is null
109      */
110     @NonNull ComparableMatchBuilder<O, Uint8> leaf(Uint8LeafReference<T> methodRef);
111
112     /**
113      * Match an {@code uint16} leaf's value.
114      *
115      * @param methodRef method reference to the getter method
116      * @return A {@link ComparableMatchBuilder}
117      * @throws NullPointerException if methodRef is null
118      */
119     @NonNull ComparableMatchBuilder<O, Uint16> leaf(Uint16LeafReference<T> methodRef);
120
121     /**
122      * Match an {@code uint32} leaf's value.
123      *
124      * @param methodRef method reference to the getter method
125      * @return A {@link ComparableMatchBuilder}
126      * @throws NullPointerException if methodRef is null
127      */
128     @NonNull ComparableMatchBuilder<O, Uint32> leaf(Uint32LeafReference<T> methodRef);
129
130     /**
131      * Match an {@code uint64} leaf's value.
132      *
133      * @param methodRef method reference to the getter method
134      * @return A {@link ComparableMatchBuilder}
135      * @throws NullPointerException if methodRef is null
136      */
137     @NonNull ComparableMatchBuilder<O, Uint64> leaf(Uint64LeafReference<T> methodRef);
138
139     /**
140      * Match an {@code identityref} leaf's value.
141      *
142      * @param methodRef method reference to the getter method
143      * @return A {@link ValueMatchBuilder}
144      * @throws NullPointerException if methodRef is null
145      */
146     <I extends BaseIdentity> @NonNull ValueMatchBuilder<O, I> leaf(IdentityLeafReference<T, I> methodRef);
147
148     /**
149      * Match a generic leaf value.
150      *
151      * @param methodRef method reference to the getter method
152      * @return A {@link ValueMatchBuilder}
153      * @throws NullPointerException if methodRef is null
154      */
155     <C extends TypeObject> @NonNull ValueMatchBuilder<O, C> leaf(TypeObjectLeafReference<T, C> methodRef);
156
157     /**
158      * Base interface for capturing binding getter method references through lambda expressions. This interface should
159      * never be used directly, but rather through one of its specializations.
160      *
161      * <p>
162      * This interface uncharacteristically extends {@link Serializable} for the purposes of making the resulting lambda
163      * also Serializable. This part is critical for the process of introspection into the lambda and identifying the
164      * method being invoked.
165      *
166      * @param <P> Parent type
167      * @param <C> Child type
168      */
169     @FunctionalInterface
170     public interface LeafReference<P, C> extends Serializable {
171         /**
172          * Dummy method to express the method signature of a typical getter. Due to this match we can match any Java
173          * method reference which takes in {@code parent} and results in {@code child} -- expose the feature of using
174          * {@code Parent::getChild} method shorthand.
175          *
176          * @param parent Parent object
177          * @return Leaf value
178          * @deprecated This method is present only for technical realization of taking the method reference and should
179          *             never be involved directly. See {@code LambdaDecoder} for gory details.
180          */
181         @Deprecated(forRemoval = true)
182         C dummyMethod(P parent);
183     }
184
185     @FunctionalInterface
186     public interface EmptyLeafReference<P> extends LeafReference<P, Empty> {
187
188     }
189
190     @FunctionalInterface
191     public interface StringLeafReference<P> extends LeafReference<P, String> {
192
193     }
194
195     @FunctionalInterface
196     public interface Int8LeafReference<P> extends LeafReference<P, Byte> {
197
198     }
199
200     @FunctionalInterface
201     public interface Int16LeafReference<P> extends LeafReference<P, Short> {
202
203     }
204
205     @FunctionalInterface
206     public interface Int32LeafReference<P> extends LeafReference<P, Integer> {
207
208     }
209
210     @FunctionalInterface
211     public interface Int64LeafReference<P> extends LeafReference<P, Long> {
212
213     }
214
215     @FunctionalInterface
216     public interface Uint8LeafReference<P> extends LeafReference<P, Uint8> {
217
218     }
219
220     @FunctionalInterface
221     public interface Uint16LeafReference<P> extends LeafReference<P, Uint16> {
222
223     }
224
225     @FunctionalInterface
226     public interface Uint32LeafReference<P> extends LeafReference<P, Uint32> {
227
228     }
229
230     @FunctionalInterface
231     public interface Uint64LeafReference<P> extends LeafReference<P, Uint64> {
232
233     }
234
235     @FunctionalInterface
236     public interface IdentityLeafReference<P, T extends BaseIdentity> extends LeafReference<P, T> {
237
238     }
239
240     @FunctionalInterface
241     public interface TypeObjectLeafReference<P, T extends TypeObject> extends LeafReference<P, T> {
242
243     }
244 }