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.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;
26 public interface MatchBuilderPath<O extends DataObject, T extends DataObject> extends Mutable {
28 * Descend match into a child container.
30 * @param <N> Child container type
31 * @param childClass Child container type class
32 * @return This builder
33 * @throws NullPointerException if childClass is null
35 <N extends ChildOf<? super T>> @NonNull MatchBuilderPath<O, N> childObject(Class<N> childClass);
38 * Descend match into a child container in a particular case.
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
46 <C extends ChoiceIn<? super T> & DataObject, N extends ChildOf<? super C>>
47 @NonNull MatchBuilderPath<O, N> extractChild(Class<C> caseClass, Class<N> childClass);
50 * Match an {@code empty} leaf's value.
52 * @param methodRef method reference to the getter method
53 * @return A {@link ValueMatchBuilder}
54 * @throws NullPointerException if methodRef is null
56 @NonNull ValueMatchBuilder<O, Empty> leaf(EmptyLeafReference<T> methodRef);
59 * Match an {@code string} leaf's value.
61 * @param methodRef method reference to the getter method
62 * @return A {@link StringMatchBuilder}
63 * @throws NullPointerException if methodRef is null
65 @NonNull StringMatchBuilder<O> leaf(StringLeafReference<T> methodRef);
68 * Match an {@code int8} leaf's value.
70 * @param methodRef method reference to the getter method
71 * @return A {@link ComparableMatchBuilder}
72 * @throws NullPointerException if methodRef is null
74 @NonNull ComparableMatchBuilder<O, Byte> leaf(Int8LeafReference<T> methodRef);
77 * Match an {@code int16} leaf's value.
79 * @param methodRef method reference to the getter method
80 * @return A {@link ComparableMatchBuilder}
81 * @throws NullPointerException if methodRef is null
83 @NonNull ComparableMatchBuilder<O, Short> leaf(Int16LeafReference<T> methodRef);
86 * Match an {@code int32} leaf's value.
88 * @param methodRef method reference to the getter method
89 * @return A {@link ComparableMatchBuilder}
90 * @throws NullPointerException if methodRef is null
92 @NonNull ComparableMatchBuilder<O, Integer> leaf(Int32LeafReference<T> methodRef);
95 * Match an {@code int64} leaf's value.
97 * @param methodRef method reference to the getter method
98 * @return A {@link ComparableMatchBuilder}
99 * @throws NullPointerException if methodRef is null
101 @NonNull ComparableMatchBuilder<O, Long> leaf(Int64LeafReference<T> methodRef);
104 * Match an {@code uint8} leaf's value.
106 * @param methodRef method reference to the getter method
107 * @return A {@link ComparableMatchBuilder}
108 * @throws NullPointerException if methodRef is null
110 @NonNull ComparableMatchBuilder<O, Uint8> leaf(Uint8LeafReference<T> methodRef);
113 * Match an {@code uint16} leaf's value.
115 * @param methodRef method reference to the getter method
116 * @return A {@link ComparableMatchBuilder}
117 * @throws NullPointerException if methodRef is null
119 @NonNull ComparableMatchBuilder<O, Uint16> leaf(Uint16LeafReference<T> methodRef);
122 * Match an {@code uint32} leaf's value.
124 * @param methodRef method reference to the getter method
125 * @return A {@link ComparableMatchBuilder}
126 * @throws NullPointerException if methodRef is null
128 @NonNull ComparableMatchBuilder<O, Uint32> leaf(Uint32LeafReference<T> methodRef);
131 * Match an {@code uint64} leaf's value.
133 * @param methodRef method reference to the getter method
134 * @return A {@link ComparableMatchBuilder}
135 * @throws NullPointerException if methodRef is null
137 @NonNull ComparableMatchBuilder<O, Uint64> leaf(Uint64LeafReference<T> methodRef);
140 * Match an {@code identityref} leaf's value.
142 * @param methodRef method reference to the getter method
143 * @return A {@link ValueMatchBuilder}
144 * @throws NullPointerException if methodRef is null
146 <I extends BaseIdentity> @NonNull ValueMatchBuilder<O, I> leaf(IdentityLeafReference<T, I> methodRef);
149 * Match a generic leaf value.
151 * @param methodRef method reference to the getter method
152 * @return A {@link ValueMatchBuilder}
153 * @throws NullPointerException if methodRef is null
155 <C extends TypeObject> @NonNull ValueMatchBuilder<O, C> leaf(TypeObjectLeafReference<T, C> methodRef);
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.
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.
166 * @param <P> Parent type
167 * @param <C> Child type
170 public interface LeafReference<P, C> extends Serializable {
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.
176 * @param parent Parent object
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.
181 @Deprecated(forRemoval = true)
182 C dummyMethod(P parent);
186 public interface EmptyLeafReference<P> extends LeafReference<P, Empty> {
191 public interface StringLeafReference<P> extends LeafReference<P, String> {
196 public interface Int8LeafReference<P> extends LeafReference<P, Byte> {
201 public interface Int16LeafReference<P> extends LeafReference<P, Short> {
206 public interface Int32LeafReference<P> extends LeafReference<P, Integer> {
211 public interface Int64LeafReference<P> extends LeafReference<P, Long> {
216 public interface Uint8LeafReference<P> extends LeafReference<P, Uint8> {
221 public interface Uint16LeafReference<P> extends LeafReference<P, Uint16> {
226 public interface Uint32LeafReference<P> extends LeafReference<P, Uint32> {
231 public interface Uint64LeafReference<P> extends LeafReference<P, Uint64> {
236 public interface IdentityLeafReference<P, T extends BaseIdentity> extends LeafReference<P, T> {
241 public interface TypeObjectLeafReference<P, T extends TypeObject> extends LeafReference<P, T> {