2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.api.query;
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.Identifiable;
19 import org.opendaylight.yangtools.yang.binding.Identifier;
20 import org.opendaylight.yangtools.yang.binding.TypeObject;
21 import org.opendaylight.yangtools.yang.common.Empty;
22 import org.opendaylight.yangtools.yang.common.Uint16;
23 import org.opendaylight.yangtools.yang.common.Uint32;
24 import org.opendaylight.yangtools.yang.common.Uint64;
25 import org.opendaylight.yangtools.yang.common.Uint8;
28 public interface MatchBuilderPath<O extends DataObject, T extends DataObject> extends Mutable {
30 * Descend match into a child container.
32 * @param <N> Child container type
33 * @param childClass Child container type class
34 * @return This builder
35 * @throws NullPointerException if childClass is null
37 <N extends ChildOf<? super T>> @NonNull MatchBuilderPath<O, N> childObject(Class<N> childClass);
40 * Descend match into a child container in a particular case.
42 * @param <C> Case type
43 * @param <N> Child container type
44 * @param childClass Child container type class
45 * @return This builder
46 * @throws NullPointerException if any argument is null
48 <C extends ChoiceIn<? super T> & DataObject, N extends ChildOf<? super C>>
49 @NonNull MatchBuilderPath<O, N> extractChild(Class<C> caseClass, Class<N> childClass);
52 * Add a child path component to the specification of what needs to be extracted, specifying an exact match in
53 * a keyed list. This method, along with its alternatives, can be used to specify which object type to select from
56 * @param <N> List type
58 * @param listKey List key
59 * @return This builder
60 * @throws NullPointerException if childClass is null
62 <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>>
63 @NonNull MatchBuilderPath<O, N> extractChild(Class<@NonNull N> listItem, K listKey);
66 * Match an {@code empty} leaf's value.
68 * @param methodRef method reference to the getter method
69 * @return A {@link ValueMatchBuilder}
70 * @throws NullPointerException if methodRef is null
72 @NonNull ValueMatchBuilder<O, Empty> leaf(EmptyLeafReference<T> methodRef);
75 * Match an {@code string} leaf's value.
77 * @param methodRef method reference to the getter method
78 * @return A {@link StringMatchBuilder}
79 * @throws NullPointerException if methodRef is null
81 @NonNull StringMatchBuilder<O> leaf(StringLeafReference<T> methodRef);
84 * Match an {@code int8} leaf's value.
86 * @param methodRef method reference to the getter method
87 * @return A {@link ComparableMatchBuilder}
88 * @throws NullPointerException if methodRef is null
90 @NonNull ComparableMatchBuilder<O, Byte> leaf(Int8LeafReference<T> methodRef);
93 * Match an {@code int16} leaf's value.
95 * @param methodRef method reference to the getter method
96 * @return A {@link ComparableMatchBuilder}
97 * @throws NullPointerException if methodRef is null
99 @NonNull ComparableMatchBuilder<O, Short> leaf(Int16LeafReference<T> methodRef);
102 * Match an {@code int32} leaf's value.
104 * @param methodRef method reference to the getter method
105 * @return A {@link ComparableMatchBuilder}
106 * @throws NullPointerException if methodRef is null
108 @NonNull ComparableMatchBuilder<O, Integer> leaf(Int32LeafReference<T> methodRef);
111 * Match an {@code int64} leaf's value.
113 * @param methodRef method reference to the getter method
114 * @return A {@link ComparableMatchBuilder}
115 * @throws NullPointerException if methodRef is null
117 @NonNull ComparableMatchBuilder<O, Long> leaf(Int64LeafReference<T> methodRef);
120 * Match an {@code uint8} leaf's value.
122 * @param methodRef method reference to the getter method
123 * @return A {@link ComparableMatchBuilder}
124 * @throws NullPointerException if methodRef is null
126 @NonNull ComparableMatchBuilder<O, Uint8> leaf(Uint8LeafReference<T> methodRef);
129 * Match an {@code uint16} leaf's value.
131 * @param methodRef method reference to the getter method
132 * @return A {@link ComparableMatchBuilder}
133 * @throws NullPointerException if methodRef is null
135 @NonNull ComparableMatchBuilder<O, Uint16> leaf(Uint16LeafReference<T> methodRef);
138 * Match an {@code uint32} leaf's value.
140 * @param methodRef method reference to the getter method
141 * @return A {@link ComparableMatchBuilder}
142 * @throws NullPointerException if methodRef is null
144 @NonNull ComparableMatchBuilder<O, Uint32> leaf(Uint32LeafReference<T> methodRef);
147 * Match an {@code uint64} leaf's value.
149 * @param methodRef method reference to the getter method
150 * @return A {@link ComparableMatchBuilder}
151 * @throws NullPointerException if methodRef is null
153 @NonNull ComparableMatchBuilder<O, Uint64> leaf(Uint64LeafReference<T> methodRef);
156 * Match an {@code identityref} leaf's value.
158 * @param methodRef method reference to the getter method
159 * @return A {@link ValueMatchBuilder}
160 * @throws NullPointerException if methodRef is null
162 <I extends BaseIdentity> @NonNull ValueMatchBuilder<O, I> leaf(IdentityLeafReference<T, I> methodRef);
165 * Match a generic leaf value.
167 * @param methodRef method reference to the getter method
168 * @return A {@link ValueMatchBuilder}
169 * @throws NullPointerException if methodRef is null
171 <C extends TypeObject> @NonNull ValueMatchBuilder<O, C> leaf(TypeObjectLeafReference<T, C> methodRef);
174 * Base interface for capturing binding getter method references through lambda expressions. This interface should
175 * never be used directly, but rather through one of its specializations.
178 * This interface uncharacteristically extends {@link Serializable} for the purposes of making the resulting lambda
179 * also Serializable. This part is critical for the process of introspection into the lambda and identifying the
180 * method being invoked.
182 * @param <P> Parent type
183 * @param <C> Child type
186 public interface LeafReference<P, C> extends Serializable {
188 * Dummy method to express the method signature of a typical getter. Due to this match we can match any Java
189 * method reference which takes in {@code parent} and results in {@code child} -- expose the feature of using
190 * {@code Parent::getChild} method shorthand.
192 * @param parent Parent object
194 * @deprecated This method is present only for technical realization of taking the method reference and should
195 * never be involved directly. See {@code LambdaDecoder} for gory details.
197 @Deprecated(forRemoval = true)
198 C dummyMethod(P parent);
202 public interface EmptyLeafReference<P> extends LeafReference<P, Empty> {
207 public interface StringLeafReference<P> extends LeafReference<P, String> {
212 public interface Int8LeafReference<P> extends LeafReference<P, Byte> {
217 public interface Int16LeafReference<P> extends LeafReference<P, Short> {
222 public interface Int32LeafReference<P> extends LeafReference<P, Integer> {
227 public interface Int64LeafReference<P> extends LeafReference<P, Long> {
232 public interface Uint8LeafReference<P> extends LeafReference<P, Uint8> {
237 public interface Uint16LeafReference<P> extends LeafReference<P, Uint16> {
242 public interface Uint32LeafReference<P> extends LeafReference<P, Uint32> {
247 public interface Uint64LeafReference<P> extends LeafReference<P, Uint64> {
252 public interface IdentityLeafReference<P, T extends BaseIdentity> extends LeafReference<P, T> {
257 public interface TypeObjectLeafReference<P, T extends TypeObject> extends LeafReference<P, T> {