Class BoxStructLiteral

All Implemented Interfaces:
IBoxLiteral, BoxVisitable

public class BoxStructLiteral extends BoxExpression implements IBoxLiteral
A struct literal comes in two forms, ordered and unordered (default). The unordered struct uses curly braces `{}` like a JSON object. The ordered struct, uses square brackets `[]` like an array literal. The difference is structs use a comma-delimited list of key/value pairs. Note, key/value pairs ANYWHERE in Boxlang can either be specified as ` foo=bar` OR `foo : bar`. This goes for strut literals, function parameters, or class/UDF metadata.
  • Constructor Details

    • BoxStructLiteral

      public BoxStructLiteral(BoxStructType type, List<BoxExpression> values, Position position, String sourceText)
      Creates the AST node for Struct Literals
      Parameters:
      values - initialization values
      position - position of the statement in the source code
      sourceText - source code that originated the Node
  • Method Details

    • getValues

      public List<BoxExpression> getValues()
    • getType

      public BoxStructType getType()
    • isLiteral

      public boolean isLiteral()
      Description copied from class: BoxExpression
      Utility method to detect if an expression node is a terminal Literal
      Overrides:
      isLiteral in class BoxExpression
      Returns:
      true if it is false otherwise
    • setValues

      public void setValues(List<BoxExpression> values)
    • setType

      public void setType(BoxStructType type)
    • toMap

      public Map<String,Object> toMap()
      Overrides:
      toMap in class BoxNode
    • accept

      public void accept(VoidBoxVisitor v)
      Description copied from interface: BoxVisitable
      Accept method for visitor support.
      Specified by:
      accept in interface BoxVisitable
      Parameters:
      v - the visitor implementation
    • accept

      public BoxNode accept(ReplacingBoxVisitor v)
      Description copied from interface: BoxVisitable
      Accept method for replacing visitor support. Each accept returns the node, or a replacement node.
      Specified by:
      accept in interface BoxVisitable
      Parameters:
      v - the visitor implementation
    • getDescription

      public String getDescription()
      Description copied from class: BoxNode
      Returns a human-readable description of the node, which it manufactures from the class name.

      While that is quite often good enough, override this method in subclasses to provide a better description when this default does not work quite right.

      Overrides:
      getDescription in class BoxNode
      Returns:
      human readable description of the expression, for use in error messages etc