public interface ObjectFactory
A factory for producing certain
SymbolicObjects.-
Method Summary
Modifier and TypeMethodDescriptionbooleanObject(boolean value) <T extends SymbolicObject>
Tcanonic(T object) Returns the canonic representative of the object's equivalence class.<T extends SymbolicObject>
voidcanonize(T[] objectArray) Canonizes each object in an array.charObject(char value) Returns aComparatoron allSymbolicObjects.<T extends SymbolicExpression>
SymbolicSequence<T> Returns the empty sequence.falseObj()voidinit()Initializes the fields of this factory.intObject(int value) numberObject(Number value) intobjectWithId(int index) Gets the canonic object with the given ID number.<T extends SymbolicExpression>
SymbolicSequence<T> Returns aSymbolicSequencecomprising the given sequence of elements.<T extends SymbolicExpression>
SymbolicSequence<T> sequence(T[] elements) Returns aSymbolicSequencecomprising the sequence of elements specified as an array.voidSets the expression comparator for this object factory.voidSets the type comparator of for this factory.voidSets the type sequence comparator of this factory.<T extends SymbolicExpression>
SymbolicSequence<T> singletonSequence(T element) Returns the sequence of length 1 consisting of the given element.stringObject(String string) trueObj()
-
Method Details
-
numberFactory
NumberFactory numberFactory()- Returns:
- the numberFactory of the ObjectFactory
-
setExpressionComparator
Sets the expression comparator for this object factory. This needs to be done before this factory is initialized with methodinit().- Parameters:
c- the expression comparator
-
setTypeComparator
Sets the type comparator of for this factory. This needs to be done before this factory is initialized with methodinit().- Parameters:
c- the type comparator
-
setTypeSequenceComparator
Sets the type sequence comparator of this factory. This needs to be done before this factory is initialized with methodinit().- Parameters:
c- the type sequence comparator
-
init
void init()Initializes the fields of this factory. Preconditions: The expression comparator, collection comparator, type comparator, and type sequence comparator have all been set for this object. -
comparator
Comparator<SymbolicObject> comparator()Returns aComparatoron allSymbolicObjects. This object comparator is based on the expression comparator, collection comparator, type comparator, and type sequence comparator that were provided to this factory. Preconditions: the factory has been initialized via methodinit()- Returns:
- the object comparator
-
canonic
Returns the canonic representative of the object's equivalence class. This will be used for the "canonicalization" of all symbolic objects in a universe. See "Flyweight Pattern".- Parameters:
object- any symbolic object- Returns:
- the canonic representative
-
canonize
Canonizes each object in an array.- Parameters:
objectArray- array ofSymbolicObjects, none of which isnull- See Also:
-
trueObj
BooleanObject trueObj()- Returns:
- the
BooleanObjectwith value true
-
falseObj
BooleanObject falseObj()- Returns:
- the
BooleanObjectwith value false
-
zeroIntObj
IntObject zeroIntObj()- Returns:
- the
IntObjectwith value 0
-
oneIntObj
IntObject oneIntObj()- Returns:
- the
IntObjectwith value 1
-
zeroIntegerObj
NumberObject zeroIntegerObj()- Returns:
- the
NumberObjectwith value () 0invalid reference
IntegerNumber
-
oneIntegerObj
NumberObject oneIntegerObj()- Returns:
- the
NumberObjectwith value () 1invalid reference
IntegerNumber
-
zeroRealObj
NumberObject zeroRealObj()- Returns:
- the
NumberObjectwith value () 0invalid reference
RationalNumber
-
oneRealObj
NumberObject oneRealObj()- Returns:
- the
NumberObjectwith value () 1invalid reference
RationalNumber
-
numberObject
- Returns:
- the
NumberObjectwrapping the given value
-
charObject
- Returns:
- the
CharObjectwrapping the given char
-
stringObject
- Returns:
- the
StringObjectwrapping the given string
-
intObject
- Returns:
- the
IntObjectwrapping the given int
-
booleanObject
- Returns:
- the
BooleanObjectwrapping the given boolean value
-
objectWithId
Gets the canonic object with the given ID number. This factory stores all canonic objects. This method should return the object in constant time. Preconditions: theindexshould in the range [0,n), where n is the current number of canonic objects.- Returns:
- the canonic object with the given ID number
-
numObjects
int numObjects()- Returns:
- the current number of canonic objects
-
sequence
Returns aSymbolicSequencecomprising the given sequence of elements. The elements must all be non-null.- Parameters:
elements- any object providing an iterator overSymbolicExpression- Returns:
- a single
SymbolicSequencewhich wraps the given list of elements
-
sequence
Returns aSymbolicSequencecomprising the sequence of elements specified as an array.- Parameters:
elements- any array ofSymbolicExpression, all elements of which must be non-null- Returns:
- a single
SymbolicSequencewhich wraps the given list of elements
-
singletonSequence
Returns the sequence of length 1 consisting of the given element.- Parameters:
element- a non-nullelement of T- Returns:
- the sequence consisting of just the one element
-
emptySequence
Returns the empty sequence.- Returns:
- the empty sequence
-