Interface Environment

All Known Subinterfaces:
FluentEnvironment<X>, Knowledge, Rule, RuleBuilder<C>, RuleDescriptor, RuleSession<S>, RuleSetBuilder<C>, RuleSetContext<C,R>, RuntimeContext<C>, RuntimeRule, StatefulSession, StatelessSession
All Known Implementing Classes:
AbstractEnvironment, AbstractSessionWrapper, KnowledgeWrapper

public interface Environment
The Environment interface provides a way to store and retrieve property values. It allows setting and getting properties with a specified name and value. Additionally, it provides a method to retrieve all property names in the environment.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    get(String property)
    Retrieves the value of a property by its name.
    default <T> T
    get(String name, T defaultValue)
    Retrieves the value of a property by its name.
    Retrieves a collection of all property names in the environment.
    set(String property, Object value)
    Sets a property in the environment with the specified name and value.
  • Method Details

    • set

      Object set(String property, Object value)
      Sets a property in the environment with the specified name and value.
      Parameters:
      property - The name of the property to be set.
      value - The value of the property to be set.
      Returns:
      The previous value of the property, or null if it did not have one.
    • get

      <T> T get(String property)
      Retrieves the value of a property by its name.
      Type Parameters:
      T - The expected type of the property value.
      Parameters:
      property - The name of the property to retrieve.
      Returns:
      The value of the property as type T, or null if it does not exist.
    • get

      default <T> T get(String name, T defaultValue)
      Retrieves the value of a property by its name. If the property does not exist, it returns a default value specified by the caller.
      Type Parameters:
      T - The expected type of the property value.
      Parameters:
      name - The name of the property to retrieve.
      defaultValue - The default value to return if the property does not exist.
      Returns:
      The value of the property as type T, or the defaultValue if the property does not exist.
    • getPropertyNames

      Collection<String> getPropertyNames()
      Retrieves a collection of all property names in the environment.
      Returns:
      A collection of strings representing all property names in the environment.