Class Schema.Builder

java.lang.Object
com.mackenziehigh.sexpr.Schema.Builder
Enclosing class:
Schema

public static final class Schema.Builder extends Object
Use an instance of this class to create a Schema object.
  • Method Details

    • include

      public Schema.Builder include(String schema)
    • include

      public Schema.Builder include(String source, String schema)
      This method imports the schema rules defined in the given string.
      Parameters:
      source - is a human-readable string indicating where the schema is from.
      schema - is the textual schema to parse.
      Returns:
      this.
    • condition

      public Schema.Builder condition(String name, Predicate<Sexpr<?>> condition)
      Use this method to define a predicate that can be used within a schema.

      Inside of the schema, the predicate must be referenced via a 'require' rule.

      Parameters:
      name - is the name that will be used to identify the predicate.
      condition - is the predicate itself.
      Returns:
      this.
      Throws:
      IllegalArgumentException - if the name already identifies a predicate.
    • pass

      public Schema.Builder pass(String name)
      Use this method to declare another translation pass.

      Call this method multiple times in order to declare multiple passes. The translation passes will occur in the order of those invocations.

      Parameters:
      name - is the name of the new translation pass.
      Returns:
      this.
    • before

      public Schema.Builder before(String pass, String rule, Consumer<Sexpr<?>> action)
      Use this method to define an action that will be executed before matches of a named rule during a specific pass.
      Parameters:
      pass - is the name of the pass that this action applies to.
      rule - is the name of the rule that this action applies to.
      action - is the action itself.
      Returns:
      this.
      Throws:
      IllegalArgumentException - if the name already identifies a action.
    • after

      public Schema.Builder after(String pass, String rule, Consumer<Sexpr<?>> action)
      Use this method to define an action that will be executed after matches of a named rule during a specific pass.
      Parameters:
      pass - is the name of the pass that this action applies to.
      rule - is the name of the rule that this action applies to.
      action - is the action itself.
      Returns:
      this.
      Throws:
      IllegalArgumentException - if the name already identifies a action.
    • defineViaAnnotations

      public Schema.Builder defineViaAnnotations(Object object)
      Given an object containing properly annotated methods, define the conditions and actions defined therein.
      Parameters:
      object - contains condition and action definitions.
      Returns:
      this.
    • build

      public Schema build()
      Use this method to obtain the new schema object.
      Returns:
      the new matcher.