Add a simple Binding query language
[mdsal.git] / binding / mdsal-binding-api / src / main / java / org / opendaylight / mdsal / binding / api / query / StringMatchBuilder.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.util.regex.Pattern;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.binding.DataObject;
14
15 /**
16  * Builder for a match of a String leaf value.
17  *
18  * @param <T> query result type
19  */
20 @Beta
21 public interface StringMatchBuilder<T extends DataObject> extends ValueMatchBuilder<T, String> {
22     /**
23      * Match if the leaf exists and its value starts with specified string, i.e. its {@link String#startsWith(String)}
24      * would return true.
25      *
26      * @param str string to match as prefix
27      * @return A ValueMatch
28      * @throws NullPointerException if str is null
29      */
30     @NonNull ValueMatch<T> startsWith(String str);
31
32     /**
33      * Match if the leaf exists and its value ends with specified string. i.e. its {@link String#endsWith(String)}
34      * would return true.
35      *
36      * @param str string to match as suffix
37      * @return A ValueMatch
38      * @throws NullPointerException if str is null
39      */
40     @NonNull ValueMatch<T> endsWith(String str);
41
42     /**
43      * Match if the leaf exists and its value contains specified string, i.e. its {@link String#contains(CharSequence)}
44      * would return true.
45      *
46      * @param str the string to search for
47      * @return A ValueMatch
48      * @throws NullPointerException if str is null
49      */
50     @NonNull ValueMatch<T> contains(String str);
51
52     /**
53      * Match if the leaf exists and its value matches with specified pattern.
54      *
55      * @param pattern pattern to check against
56      * @return A ValueMatch
57      * @throws NullPointerException if pattern is null
58      */
59     @NonNull ValueMatch<T> matchesPattern(Pattern pattern);
60 }