2 * Copyright (c) 2013 Cisco Systems, Inc. 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.yangtools.yang.model.api.type;
10 import java.util.Optional;
11 import java.util.regex.Pattern;
12 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
15 * Contains the method for getting the data from the YANG <code>pattern</code> which is substatement
16 * of <code>type</code> statement.
18 public interface PatternConstraint extends ConstraintMetaDefinition {
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()}.
25 * @return string Java Pattern regular expression
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();
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.
36 * @return argument of pattern statement as it was declared in YANG model.
38 String getRegularExpressionString();
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.
44 * @return modifier, if present
46 Optional<ModifierKind> getModifier();