org.eclipse.ocl.examples.domain.values.impl
Class AbstractCollectionValue<C extends java.util.Collection<Value>>

java.lang.Object
  extended by org.eclipse.ocl.examples.domain.values.impl.AbstractValue
      extended by org.eclipse.ocl.examples.domain.values.impl.AbstractedCollectionValue
          extended by org.eclipse.ocl.examples.domain.values.impl.AbstractCollectionValue<C>
All Implemented Interfaces:
java.lang.Iterable<Value>, CollectionValue, Value
Direct Known Subclasses:
AbstractSequenceValue, BagValueImpl, OrderedSetValueImpl, SetValueImpl

public abstract class AbstractCollectionValue<C extends java.util.Collection<Value>>
extends AbstractedCollectionValue


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.ocl.examples.domain.values.CollectionValue
CollectionValue.Accumulator
 
Field Summary
protected  C elements
           
 
Fields inherited from class org.eclipse.ocl.examples.domain.values.impl.AbstractedCollectionValue
type
 
Fields inherited from class org.eclipse.ocl.examples.domain.values.impl.AbstractValue
valueFactory
 
Fields inherited from interface org.eclipse.ocl.examples.domain.values.Value
INVALID_NAME
 
Constructor Summary
protected AbstractCollectionValue(ValueFactory valueFactory, DomainCollectionType type, C elements)
           
 
Method Summary
 BagValue asBagValue()
          Add a value to a working collection, returning true if the working collection is changed by the addition.
 java.lang.Object asEcoreObject()
          Return the Ecore representation of this value.
 OrderedSetValue asOrderedSetValue()
           
 SequenceValue asSequenceValue()
           
 SetValue asSetValue()
           
 IntegerValue count(Value value)
          Implementation of the OCL Collection::count(object : T) : Integer operation.
 BooleanValue excludes(Value value)
          Implementation of the OCL Collection::excludes(object : T) : Boolean operation.
 BooleanValue excludesAll(CollectionValue c)
          Implementation of the OCL Collection::excludesAll(c : Collection(T)) : Boolean operation.
 boolean flatten(java.util.Collection<Value> flattenedElements)
          Returns true if any element flattened.
 DomainCollectionType getBagType()
           
 DomainCollectionType getCollectionType()
           
protected  java.util.Collection<Value> getElements()
           
protected  DomainType getElementType()
           
 DomainCollectionType getOrderedSetType()
           
 DomainCollectionType getSequenceType()
           
 DomainCollectionType getSetType()
           
 int hashCode()
           
 BooleanValue includes(Value value)
           
 BooleanValue includesAll(CollectionValue c)
          Implementation of the OCL Collection::includesAll(c : Collection(T)) : Boolean operation.
 CollectionValue intersection(CollectionValue c)
           
 int intSize()
           
 java.util.Iterator<Value> iterator()
           
 Value maxMin(DomainEvaluator evaluator, DomainType returnType, LibraryBinaryOperation binaryOperation)
           
 java.util.Set<TupleValue> product(CollectionValue c, DomainTupleType tupleType)
           
 CollectionValue selectByKind(DomainType requiredElementType)
           
 CollectionValue selectByType(DomainType requiredElementType)
           
 Value sum(DomainEvaluator evaluator, DomainType returnType, LibraryBinaryOperation binaryOperation, Value zero)
           
 CollectionValue union(CollectionValue c)
           
 
Methods inherited from class org.eclipse.ocl.examples.domain.values.impl.AbstractedCollectionValue
asCollection, asCollectionValue, asList, asObject, asValidValue, getActualType, getType, isCollectionValue, isEmpty, notEmpty, size, toString, toString
 
Methods inherited from class org.eclipse.ocl.examples.domain.values.impl.AbstractValue
asBoolean, asBooleanValue, asDouble, asElement, asElementValue, asInteger, asIntegerValue, asNavigableObject, asObjectValue, asRealValue, asString, asStringValue, asTypeValue, asUniqueCollectionValue, getValueFactory, isFalse, isIntegerValue, isInvalid, isNull, isRealValue, isTrue, isUndefined, isUnlimited, isUnlimitedNatural, oclToString, toIntegerValue, toIteratorValue, toRealValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.ocl.examples.domain.values.CollectionValue
excluding, flatten, getKind, including, sort, toSequenceValue
 
Methods inherited from interface org.eclipse.ocl.examples.domain.values.Value
asBoolean, asBooleanValue, asDouble, asElement, asElementValue, asInteger, asIntegerValue, asNavigableObject, asObjectValue, asRealValue, asString, asStringValue, asTypeValue, asUniqueCollectionValue, getValueFactory, isFalse, isIntegerValue, isInvalid, isNull, isRealValue, isTrue, isUndefined, isUnlimited, isUnlimitedNatural, oclToString, toIntegerValue, toIteratorValue, toRealValue
 

Field Detail

elements

protected final C extends java.util.Collection<Value> elements
Constructor Detail

AbstractCollectionValue

protected AbstractCollectionValue(ValueFactory valueFactory,
                                  DomainCollectionType type,
                                  C elements)
Method Detail

asBagValue

public BagValue asBagValue()
Add a value to a working collection, returning true if the working collection is changed by the addition.

The default implementation is appropriate for non-unique collections and must be overridden to support OCL rather than Java uniqueness semantics.

Specified by:
asBagValue in interface Value
Overrides:
asBagValue in class AbstractValue

asEcoreObject

public java.lang.Object asEcoreObject()
Description copied from interface: Value
Return the Ecore representation of this value.

Specified by:
asEcoreObject in interface Value
Overrides:
asEcoreObject in class AbstractValue

asOrderedSetValue

public OrderedSetValue asOrderedSetValue()
Specified by:
asOrderedSetValue in interface Value
Overrides:
asOrderedSetValue in class AbstractValue

asSequenceValue

public SequenceValue asSequenceValue()
Specified by:
asSequenceValue in interface Value
Overrides:
asSequenceValue in class AbstractValue

asSetValue

public SetValue asSetValue()
Specified by:
asSetValue in interface Value
Overrides:
asSetValue in class AbstractValue

count

public IntegerValue count(Value value)
                   throws InvalidValueException
Implementation of the OCL Collection::count(object : T) : Integer operation.

Parameters:
self - the source collection
object - an object
Returns:
the number of occurrences of the object in the collection
Throws:
InvalidValueException

excludes

public BooleanValue excludes(Value value)
Implementation of the OCL Collection::excludes(object : T) : Boolean operation.

Parameters:
self - the source collection
object - an object
Returns:
whether the collection does not include the object

excludesAll

public BooleanValue excludesAll(CollectionValue c)
Implementation of the OCL Collection::excludesAll(c : Collection(T)) : Boolean operation.

Parameters:
self - the source collection
c - another collection
Returns:
whether the source collection does not contain any of the elements of the other

flatten

public boolean flatten(java.util.Collection<Value> flattenedElements)
                throws InvalidValueException
Returns true if any element flattened.

Throws:
InvalidValueException

getBagType

public DomainCollectionType getBagType()

getCollectionType

public DomainCollectionType getCollectionType()

getElementType

protected DomainType getElementType()

getElements

protected java.util.Collection<Value> getElements()
Specified by:
getElements in class AbstractedCollectionValue

getOrderedSetType

public DomainCollectionType getOrderedSetType()

getSequenceType

public DomainCollectionType getSequenceType()

getSetType

public DomainCollectionType getSetType()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

includes

public BooleanValue includes(Value value)

includesAll

public BooleanValue includesAll(CollectionValue c)
Implementation of the OCL Collection::includesAll(c : Collection(T)) : Boolean operation.

Parameters:
self - the source collection
c - another collection
Returns:
whether the source collection includes all of the elements of the other

intSize

public int intSize()

intersection

public CollectionValue intersection(CollectionValue c)
                             throws InvalidValueException
Throws:
InvalidValueException

iterator

public java.util.Iterator<Value> iterator()

maxMin

public Value maxMin(DomainEvaluator evaluator,
                    DomainType returnType,
                    LibraryBinaryOperation binaryOperation)
             throws InvalidValueException
Throws:
InvalidValueException

product

public java.util.Set<TupleValue> product(CollectionValue c,
                                         DomainTupleType tupleType)

selectByKind

public CollectionValue selectByKind(DomainType requiredElementType)
                             throws InvalidValueException
Throws:
InvalidValueException

selectByType

public CollectionValue selectByType(DomainType requiredElementType)
                             throws InvalidValueException
Throws:
InvalidValueException

sum

public Value sum(DomainEvaluator evaluator,
                 DomainType returnType,
                 LibraryBinaryOperation binaryOperation,
                 Value zero)
          throws InvalidValueException
Throws:
InvalidValueException

union

public CollectionValue union(CollectionValue c)
                      throws InvalidValueException
Throws:
InvalidValueException