Class EnvironmentObjects
java.lang.Object
org.logicmachine.rebl.common.Some<EnvironmentObject>
org.logicmachine.rebl.language.context.EnvironmentObjects
- All Implemented Interfaces:
Iterable<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.
EnvironmentObjects can be attached to a specific scope instance or made available within the 'global' scope and hence accessible everywhere.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds 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.add
(EnvironmentObject object) Adds the given 'object' to the current operating environment.static EnvironmentObjects
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.addAll
(EnvironmentObject... objects) Adds the given 'objects' to the current operating environment.Searches this collection for an element whose key matches the given 'key' value.Searches this collection for an element whose key matches the given 'key' value.Methods inherited from class org.logicmachine.rebl.common.Some
addAll, allowNull, clear, findAll, getCollection, iterator, size, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
EnvironmentObjects
public EnvironmentObjects()Default constructor.
-
-
Method Details
-
add
Adds the given 'object' to the current operating environment.- Overrides:
add
in classSome<EnvironmentObject>
- Parameters:
object
- holds the object to be added to the environment (cannot be null)- Returns:
- a handle to self to allow chaining
-
add
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
Adds the given 'objects' to the current operating environment.- Overrides:
addAll
in classSome<EnvironmentObject>
- Parameters:
objects
- holds the objects to be added to the environment (cannot be null)- Returns:
- a handle to self to allow chaining
-
addAll
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
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
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 classSome<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
-