Clean up PatternConstraint's String confusion
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / type / PatternConstraint.java
index b2d9cfc80ccabcefe5453976fe15e16d635ab1ca..5bf8762e83a91442213eb7ab3460e35c9d3fe68b 100644 (file)
@@ -8,31 +8,34 @@
 package org.opendaylight.yangtools.yang.model.api.type;
 
 import java.util.Optional;
+import java.util.regex.Pattern;
 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
 
 /**
- * Contains the method for getting the data from the YANG <code>pattern</code> which is substatement of
- * <code>type</code> statement.
+ * Contains the method for getting the data from the YANG <code>pattern</code> which is substatement
+ * of <code>type</code> statement.
  */
 public interface PatternConstraint extends ConstraintMetaDefinition {
 
     /**
-     * Returns a java regular expression (pattern).
+     * Returns a Java {@link Pattern}-compatible regular expression (pattern). Returned string performs equivalent
+     * matching in terms of enforcement, but it may have a structure completely different from the one in YANG model.
+     * This string DOES NOT include the effects of the modifier (if present, as indicated by {@link #getModifier()}.
      *
-     * @return string with java regular expression which is equal to the argument of
-     *         the YANG <code>pattern</code> substatement
+     * @return string Java Pattern regular expression
      */
-    String getRegularExpression();
+    // FIXME: should we be providing a Pattern instance? This, along with the other method is treading the fine
+    //        balance between usability of the effective model, the purity of effective view model and memory
+    //        overhead. We pick usability and memory footprint and expose both methods from effective model.
+    String getJavaPatternString();
 
     /**
-     * Returns a raw regular expression as it was declared in a source.
+     * Returns a raw regular expression as it was declared in a source. This string conforms to XSD regular expression
+     * syntax, which is notably different from Java's Pattern string.
      *
-     * @return argument of pattern statement as it was declared in a source.
+     * @return argument of pattern statement as it was declared in YANG model.
      */
-    // FIXME: version 2.0.0: make this method non-default
-    default String getRawRegularExpression() {
-        return getRegularExpression();
-    }
+    String getRegularExpressionString();
 
     /**
      * RFC7950 allows a pattern constraint to be inverted. For this purpose a general modifier concept has been