Class DefinedObjectBuilder

java.lang.Object
edu.uky.cs.nil.sabre.io.DefinedObjectBuilder
All Implemented Interfaces:
Builder

public class DefinedObjectBuilder extends Object implements Builder
A builder which returns a defined object. This builder assumes the parse tree given to its build method has exactly one child and that the child can be built as a String. That string and the provided type will be used to find a defined object. Defined object builders are typically used for referencing named things defined in a universe, such as entities, or variables defined in the current context.
Author:
Stephen G. Ware
  • Field Details

    • type

      public final Class<?> type
      The type of the defined object
  • Constructor Details

    • DefinedObjectBuilder

      public DefinedObjectBuilder(Class<?> type)
      Constructs a new defined object builder.
      Parameters:
      type - the type of the defined object
  • Method Details

    • build

      public Object build(Parser parser, ParseTree tree, Definitions definitions) throws ParseException
      Description copied from interface: Builder
      Convert a parse tree into an object.
      Specified by:
      build in interface Builder
      Parameters:
      parser - the parser which called this method, in case it is needed to build and of the parse tree's children
      tree - the parse tree to be converted into an object
      definitions - a set of other objects which have already been defined in the same context and which may be referenced by this parse tree
      Returns:
      an object created according to the parse tree
      Throws:
      ParseException - if the parse tree does not define a valid object