Interface Expression

All Superinterfaces:
Logical
All Known Subinterfaces:
Value
All Known Implementing Classes:
Constant, Entity, Proposition, Variable

public interface Expression extends Logical
A logical expression is a logical formula that can be evaluated to return a value in a state.
Author:
Stephen G. Ware
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    configure(com.google.gson.GsonBuilder builder)
    Configures a GsonBuilder to encode and decode Expression objects as JSON.
    evaluate(State state)
    Returns the value of this logical expression in the given state.
    Returns a logical object identical to this one, except that its logical elements have been replaced according to the given substitution.
  • Method Details

    • configure

      static void configure(com.google.gson.GsonBuilder builder)
      Configures a GsonBuilder to encode and decode Expression objects as JSON.
      Parameters:
      builder - the GSON builder to configure
    • substitute

      Expression substitute(Function<Object,Object> substitution)
      Description copied from interface: Logical
      Returns a logical object identical to this one, except that its logical elements have been replaced according to the given substitution. A substitution defines how some logical formula (the input to the function) should be replaced with a different formula (the output of the function).
      Specified by:
      substitute in interface Logical
      Parameters:
      substitution - a function which maps logical formula that should be replaced to the formula they should be replaced with
      Returns:
      an identical object, except that its logical formula have been replaced according to the substitution
    • evaluate

      Value evaluate(State state)
      Returns the value of this logical expression in the given state.
      Parameters:
      state - a mapping of values to all of a story world's variables
      Returns:
      the value of the expression in the given state