Class RegularExpression

java.lang.Object
com.flowingcode.vaadin.addons.regex.RegularExpression

public final class RegularExpression extends Object
Represents a regular expression.

This class assists in the creation and handling of regular expressions by providing pre-defined operators for common patterns such as "starts with", "ends with", and "contains". It also supports an advanced mode where users can input custom regular expressions.

Instances of this class are immutable and validated upon creation.

Author:
Javier Godoy
  • Constructor Details

  • Method Details

    • of

      public static RegularExpression of(Pattern pattern)
      Creates a RegularExpression instance from a given Pattern.

      This method attempts to determine if the pattern corresponds to a simple RegularExpressionOperator like "starts with", "ends with", or "contains". If it does, a corresponding RegularExpression is returned. Otherwise, an advanced mode expression is created.

      Parameters:
      pattern - the pattern to analyze
      Returns:
      a RegularExpression instance
      Throws:
      NullPointerException - if pattern is null.
    • toString

      public String toString()
      Overrides:
      toString in class Object