Add a simple Binding query language
[mdsal.git] / binding / mdsal-binding-api / src / main / java / org / opendaylight / mdsal / binding / api / query / DescendantQueryBuilder.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.ChildOf;
13 import org.opendaylight.yangtools.yang.binding.ChoiceIn;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15
16 /**
17  * Intermediate Query builder stage, which allows the specification of the query result type to be built up via
18  * {@link #extractChild(Class)} and {@link #extractChild(Class, Class)} methods. Once completed, use either
19  * {@link #build()} to create a simple query, or {@link #matching()} to transition to specify predicates.
20  *
21  * @param <T> Query result type
22  */
23 @Beta
24 public interface DescendantQueryBuilder<T extends DataObject> extends StructuralBuilder<QueryExpression<T>> {
25     /**
26      * Add a child path component to the specification of what needs to be extracted. This method, along with its
27      * alternatives, can be used to specify which object type to select from the root path.
28      *
29      * @param <N> Container type
30      * @param childClass child container class
31      * @return This builder
32      * @throws NullPointerException if childClass is null
33      */
34     <N extends ChildOf<? super T>> @NonNull DescendantQueryBuilder<N> extractChild(Class<N> childClass);
35
36     /**
37      * Add a child path component to the specification of what needs to be extracted. This method, along with its
38      * alternatives, can be used to specify which object type to select from the root path.
39      *
40      * @param <C> Case type
41      * @param <N> Container type
42      * @param caseClass child case class
43      * @param childClass child container class
44      * @return This builder
45      * @throws NullPointerException if any argument is null
46      */
47     <C extends ChoiceIn<? super T> & DataObject, N extends ChildOf<? super C>>
48         @NonNull DescendantQueryBuilder<N> extractChild(Class<C> caseClass, Class<N> childClass);
49
50     /**
51      * Start specifying type match predicates.
52      *
53      * @return A predicate match builder based on current result type
54      */
55     @NonNull MatchBuilderPath<T, T> matching();
56
57     @Override
58     QueryExpression<T> build();
59 }