Populate data/ hierarchy
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / type / PatternConstraint.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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.yangtools.yang.model.api.type;
9
10 import java.util.Optional;
11 import java.util.regex.Pattern;
12 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
13
14 /**
15  * Contains the method for getting the data from the YANG <code>pattern</code> which is substatement
16  * of <code>type</code> statement.
17  */
18 public interface PatternConstraint extends ConstraintMetaDefinition {
19
20     /**
21      * Returns a Java {@link Pattern}-compatible regular expression (pattern). Returned string performs equivalent
22      * matching in terms of enforcement, but it may have a structure completely different from the one in YANG model.
23      * This string DOES NOT include the effects of the modifier (if present, as indicated by {@link #getModifier()}.
24      *
25      * @return string Java Pattern regular expression
26      */
27     // FIXME: should we be providing a Pattern instance? This, along with the other method is treading the fine
28     //        balance between usability of the effective model, the purity of effective view model and memory
29     //        overhead. We pick usability and memory footprint and expose both methods from effective model.
30     String getJavaPatternString();
31
32     /**
33      * Returns a raw regular expression as it was declared in a source. This string conforms to XSD regular expression
34      * syntax, which is notably different from Java's Pattern string.
35      *
36      * @return argument of pattern statement as it was declared in YANG model.
37      */
38     String getRegularExpressionString();
39
40     /**
41      * RFC7950 allows a pattern constraint to be inverted. For this purpose a general modifier concept has been
42      * introduced. A pattern can have at most one such modifier.
43      *
44      * @return modifier, if present
45      */
46     Optional<ModifierKind> getModifier();
47 }