org.eclipse.ocl.examples.domain.values.impl
Class CollectionValueImpl

java.lang.Object
  extended by org.eclipse.ocl.examples.domain.values.util.ValuesUtil
      extended by org.eclipse.ocl.examples.domain.values.impl.ValueImpl
          extended by org.eclipse.ocl.examples.domain.values.impl.CollectionValueImpl
All Implemented Interfaces:
java.lang.Iterable<java.lang.Object>, CollectionValue, Value
Direct Known Subclasses:
BagValueImpl, OrderedSetValueImpl, SequenceValueImpl, SetValueImpl

public abstract class CollectionValueImpl
extends ValueImpl
implements CollectionValue, java.lang.Iterable<java.lang.Object>

Generated
NOT

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.ocl.examples.domain.values.CollectionValue
CollectionValue.Accumulator
 
Field Summary
protected  java.util.Collection<? extends java.lang.Object> elements
           
static org.eclipse.ocl.examples.domain.values.impl.CollectionValueImpl.NullIterator EMPTY_ITERATOR
           
protected  CollectionTypeId typeId
           
 
Fields inherited from class org.eclipse.ocl.examples.domain.values.util.ValuesUtil
EMPTY_BAG, EMPTY_SET, FALSE_VALUE, INTEGER_MAX_VALUE, INTEGER_MIN_VALUE, INVALID_VALUE, LONG_MAX_VALUE, LONG_MIN_VALUE, NULL_STRING, NULL_VALUE, ONE_VALUE, TRUE_VALUE, UNLIMITED_VALUE, ZERO_VALUE
 
Fields inherited from interface org.eclipse.ocl.examples.domain.values.Value
INVALID_NAME
 
Constructor Summary
protected CollectionValueImpl(CollectionTypeId typeId, java.util.Collection<? extends java.lang.Object> values)
           
 
Method Summary
 BagValue asBagValue()
          Add a value to a working collection, returning true if the working collection is changed by the addition.
 java.util.Collection<? extends java.lang.Object> asCollection()
           
 CollectionValue asCollectionValue()
           
 java.util.List<java.lang.Object> asEcoreObject()
          Deprecated. 
 java.util.List<java.lang.Object> asEcoreObject(IdResolver idResolver)
           
<T> java.util.List<T>
asEcoreObjects(IdResolver idResolver, java.lang.Class<T> elementClass)
           
 java.util.List<? extends java.lang.Object> asList()
           
 java.lang.Object asObject()
           
 OrderedSetValue asOrderedSetValue()
           
 SequenceValue asSequenceValue()
           
 SetValue asSetValue()
           
protected  boolean checkElementsAreUnique(java.lang.Iterable<? extends java.lang.Object> elements)
           
 IntegerValue count(java.lang.Object value)
          Implementation of the OCL Collection::count(object : T) : Integer operation.
protected  org.eclipse.emf.ecore.EClass eStaticClass()
           
 java.lang.Boolean excludes(java.lang.Object value)
          Implementation of the OCL Collection::excludes(object : T) : Boolean operation.
 java.lang.Boolean excludesAll(CollectionValue c)
          Implementation of the OCL Collection::excludesAll(c : Collection(T)) : Boolean operation.
 boolean flatten(java.util.Collection<java.lang.Object> flattenedElements)
          Returns true if any element flattened.
 CollectionTypeId getBagTypeId()
           
 java.util.Collection<? extends java.lang.Object> getElements()
           
 TypeId getElementTypeId()
           
 java.util.Collection<? extends java.lang.Object> getObject()
           
 CollectionTypeId getOrderedSetTypeId()
           
 CollectionTypeId getSequenceTypeId()
           
 CollectionTypeId getSetTypeId()
           
 CollectionTypeId getTypeId()
          Return the type of this value determined from its construction context.
 int hashCode()
           
 java.lang.Boolean includes(java.lang.Object value)
           
 java.lang.Boolean includesAll(CollectionValue c)
          Implementation of the OCL Collection::includesAll(c : Collection(T)) : Boolean operation.
static void initStatics()
          A simple public static method that may be used to force class initialization.
 CollectionValue intersection(CollectionValue that)
           
 int intSize()
           
 java.lang.Boolean isEmpty()
           
 java.lang.Iterable<? extends java.lang.Object> iterable()
           
 java.util.Iterator<java.lang.Object> iterator()
           
 java.lang.Boolean notEmpty()
           
 java.util.Set<TupleValue> product(CollectionValue c, TupleTypeId tupleTypeId)
           
 IntegerValue size()
           
 java.lang.String toString()
           
 void toString(java.lang.StringBuilder s, int lengthLimit)
           
 CollectionValue union(CollectionValue that)
           
 
Methods inherited from class org.eclipse.ocl.examples.domain.values.impl.ValueImpl
asDouble, asElement, asInteger, asIntegerValue, asNavigableObject, asObjectValue, asOrderedCollectionValue, asRealValue, asTupleValue, asUniqueCollectionValue, asUnlimitedNaturalValue, getTypeName, isInvalid, isUndefined
 
Methods inherited from class org.eclipse.ocl.examples.domain.values.util.ValuesUtil
asBagValue, asBoolean, asCollectionType, asCollectionValue, asInteger, asIntegerValue, asMetaclass, asNavigableObject, asObject, asOrderedCollectionValue, asOrderedSetValue, asRealValue, asSequenceValue, asSetValue, asString, asTupleValue, asType, asUniqueCollectionValue, asUnlimitedNaturalValue, asValue, bigDecimalValueOf, bigIntegerValueOf, characterValueOf, createBagAccumulatorValue, createBagOfEach, createBagRange, createBagValue, createCollectionAccumulatorValue, createInvalidValue, createObjectValue, createOrderedSetAccumulatorValue, createOrderedSetOfEach, createOrderedSetRange, createOrderedSetValue, createRange, createSequenceAccumulatorValue, createSequenceOfEach, createSequenceRange, createSequenceRange, createSequenceValue, createSetAccumulatorValue, createSetOfEach, createSetRange, createSetValue, createTupleOfEach, createTupleValue, createTupleValue, createTypeValue, getEcoreNumber, getTypeName, initAllStatics, integerValueOf, integerValueOf, integerValueOf, integerValueOf, integerValueOf, isBoxed, isCollectionValue, isIntegerNumber, isIntegerValue, isRealNumber, isUnboxed, isUnlimited, oclToString, realValueOf, realValueOf, realValueOf, realValueOf, realValueOf, stringValueOf, throwBooleanInvalidValueException, throwInvalidValueException, toString
 
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, excludingAll, flatten, getKind, including, includingAll, isOrdered, isUnique, sort, toSequenceValue
 
Methods inherited from interface org.eclipse.ocl.examples.domain.values.Value
asDouble, asElement, asInteger, asIntegerValue, asNavigableObject, asObjectValue, asOrderedCollectionValue, asRealValue, asTupleValue, asUniqueCollectionValue, asUnlimitedNaturalValue, isInvalid, isUndefined
 

Field Detail

EMPTY_ITERATOR

@NonNull
public static org.eclipse.ocl.examples.domain.values.impl.CollectionValueImpl.NullIterator EMPTY_ITERATOR

typeId

@NonNull
protected final CollectionTypeId typeId

elements

@NonNull
protected final java.util.Collection<? extends java.lang.Object> elements
Constructor Detail

CollectionValueImpl

protected CollectionValueImpl(@NonNull
                              CollectionTypeId typeId,
                              @NonNull
                              java.util.Collection<? extends java.lang.Object> values)
Method Detail

initStatics

public static void initStatics()
A simple public static method that may be used to force class initialization.


eStaticClass

protected org.eclipse.emf.ecore.EClass eStaticClass()

Overrides:
eStaticClass in class ValueImpl
Generated

checkElementsAreUnique

protected boolean checkElementsAreUnique(java.lang.Iterable<? extends java.lang.Object> elements)

asBagValue

@NonNull
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 ValueImpl

asCollection

@NonNull
public java.util.Collection<? extends java.lang.Object> asCollection()
Specified by:
asCollection in interface CollectionValue

asCollectionValue

@NonNull
public CollectionValue asCollectionValue()
Specified by:
asCollectionValue in interface Value
Overrides:
asCollectionValue in class ValueImpl

asEcoreObject

@Deprecated
@NonNull
public java.util.List<java.lang.Object> asEcoreObject()
Deprecated. 

Description copied from interface: Value
Return the Ecore representation of this value.

An thrown exception for an invalid OCL value.

Java-null for a null OCL value

Objects for other things

Specified by:
asEcoreObject in interface CollectionValue
Specified by:
asEcoreObject in interface Value
Overrides:
asEcoreObject in class ValueImpl

asEcoreObject

@NonNull
public java.util.List<java.lang.Object> asEcoreObject(@NonNull
                                                              IdResolver idResolver)
Specified by:
asEcoreObject in interface CollectionValue
Specified by:
asEcoreObject in interface Value
Overrides:
asEcoreObject in class ValueImpl

asEcoreObjects

@NonNull
public <T> java.util.List<T> asEcoreObjects(@NonNull
                                                    IdResolver idResolver,
                                                    @NonNull
                                                    java.lang.Class<T> elementClass)
Specified by:
asEcoreObjects in interface CollectionValue

asList

@NonNull
public java.util.List<? extends java.lang.Object> asList()

asObject

@NonNull
public java.lang.Object asObject()
Specified by:
asObject in interface Value

asOrderedSetValue

@NonNull
public OrderedSetValue asOrderedSetValue()
Specified by:
asOrderedSetValue in interface Value
Overrides:
asOrderedSetValue in class ValueImpl

asSequenceValue

@NonNull
public SequenceValue asSequenceValue()
Specified by:
asSequenceValue in interface Value
Overrides:
asSequenceValue in class ValueImpl

asSetValue

@NonNull
public SetValue asSetValue()
Specified by:
asSetValue in interface Value
Overrides:
asSetValue in class ValueImpl

count

@NonNull
public IntegerValue count(@Nullable
                                  java.lang.Object value)
Implementation of the OCL Collection::count(object : T) : Integer operation.

Specified by:
count in interface CollectionValue
Parameters:
value - an object
Returns:
the number of occurrences of the object in the collection
Throws:
InvalidValueException

excludes

@NonNull
public java.lang.Boolean excludes(@Nullable
                                          java.lang.Object value)
Implementation of the OCL Collection::excludes(object : T) : Boolean operation.

Specified by:
excludes in interface CollectionValue
Parameters:
value - an object
Returns:
whether the collection does not include the object

excludesAll

@NonNull
public java.lang.Boolean excludesAll(@NonNull
                                             CollectionValue c)
Implementation of the OCL Collection::excludesAll(c : Collection(T)) : Boolean operation.

Specified by:
excludesAll in interface CollectionValue
Parameters:
c - another collection
Returns:
whether the source collection does not contain any of the elements of the other

flatten

public boolean flatten(@NonNull
                       java.util.Collection<java.lang.Object> flattenedElements)
Returns true if any element flattened.

Specified by:
flatten in interface CollectionValue
Throws:
InvalidValueException

getBagTypeId

@NonNull
public CollectionTypeId getBagTypeId()

getElementTypeId

@NonNull
public TypeId getElementTypeId()

getElements

@NonNull
public java.util.Collection<? extends java.lang.Object> getElements()
Specified by:
getElements in interface CollectionValue

getObject

@NonNull
public java.util.Collection<? extends java.lang.Object> getObject()

getOrderedSetTypeId

@NonNull
public CollectionTypeId getOrderedSetTypeId()

getSequenceTypeId

@NonNull
public CollectionTypeId getSequenceTypeId()

getSetTypeId

@NonNull
public CollectionTypeId getSetTypeId()

getTypeId

@NonNull
public CollectionTypeId getTypeId()
Description copied from interface: Value
Return the type of this value determined from its construction context. In the case of collections this may differ from the actual type.

Specified by:
getTypeId in interface CollectionValue
Specified by:
getTypeId in interface Value

hashCode

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

includes

@NonNull
public java.lang.Boolean includes(@Nullable
                                          java.lang.Object value)
Specified by:
includes in interface CollectionValue

includesAll

@NonNull
public java.lang.Boolean includesAll(@NonNull
                                             CollectionValue c)
Implementation of the OCL Collection::includesAll(c : Collection(T)) : Boolean operation.

Specified by:
includesAll in interface CollectionValue
Parameters:
c - another collection
Returns:
whether the source collection includes all of the elements of the other

intSize

public int intSize()
Specified by:
intSize in interface CollectionValue

intersection

@NonNull
public CollectionValue intersection(@NonNull
                                            CollectionValue that)
Specified by:
intersection in interface CollectionValue

isEmpty

@NonNull
public java.lang.Boolean isEmpty()
Specified by:
isEmpty in interface CollectionValue

iterable

@NonNull
public java.lang.Iterable<? extends java.lang.Object> iterable()
Specified by:
iterable in interface CollectionValue

iterator

@NonNull
public java.util.Iterator<java.lang.Object> iterator()
Specified by:
iterator in interface java.lang.Iterable<java.lang.Object>
Specified by:
iterator in interface CollectionValue

notEmpty

@NonNull
public java.lang.Boolean notEmpty()
Specified by:
notEmpty in interface CollectionValue

product

@NonNull
public java.util.Set<TupleValue> product(@NonNull
                                                 CollectionValue c,
                                                 @NonNull
                                                 TupleTypeId tupleTypeId)
Specified by:
product in interface CollectionValue

size

@NonNull
public IntegerValue size()
Specified by:
size in interface CollectionValue

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public void toString(@NonNull
                     java.lang.StringBuilder s,
                     int lengthLimit)
Specified by:
toString in interface Value
Overrides:
toString in class ValueImpl

union

@NonNull
public CollectionValue union(@NonNull
                                     CollectionValue that)
Specified by:
union in interface CollectionValue