Class EnvironmentObjects

java.lang.Object
org.logicmachine.rebl.common.Some<EnvironmentObject>
org.logicmachine.rebl.language.context.EnvironmentObjects
All Implemented Interfaces:
Iterable<EnvironmentObject>

public class EnvironmentObjects extends Some<EnvironmentObject>
Collection class holding a set of Objects forming the current operating environment.

EnvironmentObjects can be attached to a specific scope instance or made available within the 'global' scope and hence accessible everywhere.
  • Constructor Details

    • EnvironmentObjects

      public EnvironmentObjects()
      Default constructor.
  • Method Details

    • add

      Adds the given 'object' to the current operating environment.
      Overrides:
      add in class Some<EnvironmentObject>
      Parameters:
      object - holds the object to be added to the environment (cannot be null)
      Returns:
      a handle to self to allow chaining
    • add

      public EnvironmentObjects add(Object object)
      Adds the input 'object' unchanged to the current operating environment if 'object' is an instance of EnvironmentObject, otherwise this method will construct a new EnvironmentObject instance from the given 'object' and add this new instance to the current operating environment.
      Parameters:
      object - holds the object to be added to the environment (cannot be null)
      Returns:
      a handle to self to allow chaining
    • addAll

      public EnvironmentObjects addAll(EnvironmentObject... objects)
      Adds the given 'objects' to the current operating environment.
      Overrides:
      addAll in class Some<EnvironmentObject>
      Parameters:
      objects - holds the objects to be added to the environment (cannot be null)
      Returns:
      a handle to self to allow chaining
    • addAll

      public static EnvironmentObjects addAll(Object... objects)
      Returns a newly created EnvironmentObjects collection, holding the given 'objects', each of which will have been wrapped in an 'EnvironmentObject' instance before being added to the collection.

      Whilst 'objects' itself cannot be null, if any of the entries within 'objects' are null, they will simply be ignored.
      Parameters:
      objects - holds the objects to be added (cannot be null)
      Returns:
      a newly created 'EnvironmentObjects' instance populated with the given 'objects'
    • find

      public EnvironmentObject find(Object key)
      Searches this collection for an element whose key matches the given 'key' value. Returns the first matching element on match, or a non-null 'empty' instance on no match.
      Parameters:
      key - holds the key to search for (can be null)
      Returns:
      either the first element matching the given 'key', or a non-null 'empty' instance on no match
    • find

      public EnvironmentObject find(Object key, Maybe empty)
      Description copied from class: Some
      Searches this collection for an element whose key matches the given 'key' value. Returns the first matching element on match, or the given 'empty' instance on no match.

      As an implementation note, this class is backed by a Map. Therefore the 'find()' and 'findAll()' methods complete in O(1) time.

      See also the related 'Many' class which is backed by a List and whose 'find()' and 'findAll()' methods complete in O(n) time.
      Overrides:
      find in class Some<EnvironmentObject>
      Parameters:
      key - holds the key to search for (can be null)
      empty - holds the empty instance which will be returned on no match (must not be null unless the 'allowNull()' method has previously been called)
      Returns:
      either the first element matching the given 'key', or the specified 'empty' instance on no match or if 'key' is null