org.eclipse.ocl.examples.codegen.generator
Interface TypeDescriptor

All Known Subinterfaces:
BoxedDescriptor, CollectionDescriptor, SimpleDescriptor, UnboxedDescriptor
All Known Implementing Classes:
AbstractCollectionDescriptor, AbstractDescriptor, AbstractValueDescriptor, BooleanObjectDescriptor, BooleanPrimitiveDescriptor, BoxedValueDescriptor, BoxedValuesDescriptor, EnumerationObjectDescriptor, EnumerationValueDescriptor, EObjectDescriptor, EObjectsDescriptor, FutureEObjectDescriptor, FutureEObjectsDescriptor, IntegerObjectDescriptor, IntegerValueDescriptor, RealObjectDescriptor, RealValueDescriptor, RootObjectDescriptor, SimpleDataTypeDescriptor, SimpleValueDescriptor, UnboxedElementsDescriptor, UnboxedValueDescriptor, UnlimitedNaturalObjectDescriptor, UnlimitedNaturalValueDescriptor

public interface TypeDescriptor

TypeDescriptor captures the characteristics of a Java type and supports serialization to a javaStream.

Derived classes support boxed/unboxed types, static/dynamic Ecore and collections.


Method Summary
 void append(JavaStream js)
          Append the declaration of this type to a JavaStream.
 java.lang.Boolean appendBox(JavaStream js, JavaLocalContext localContext, CGBoxExp cgBoxExp, CGValuedElement unboxedValue)
           
 void appendCast(JavaStream js, java.lang.Class<?> actualJavaClass, JavaStream.SubStream subStream)
          Append the actualJavaClass subStream to js wrapped in a cast to this type.g.
 void appendCastTerm(JavaStream js, CGValuedElement cgElement)
          Append a cgElement to js wrapped in a cast to this type
 void appendEqualsValue(JavaStream js, CGValuedElement thisValue, CGValuedElement thatValue, boolean notEquals)
          Append an expression term that evaluates whether (this TypedDescriptor and) thisValue is not equals/ notEquals to thatValue.
 void appendNotEqualsTerm(JavaStream js, CGValuedElement thisValue, TypeDescriptor thatTypeDescriptor, java.lang.String thatName)
          Append an expression term that evaluates whether (this TypedDescriptor and) thisValue is not equal to thatTypeDescriptor and thatName.
 java.lang.Boolean appendUnboxStatements(JavaStream js, JavaLocalContext localContext, CGUnboxExp cgUnboxExp, CGValuedElement boxedValue)
           
 CollectionDescriptor asCollectionDescriptor()
          Return a non-null Collection type descriptor if this type descriptor dedescribes a Collection.
 java.lang.String getClassName()
          Return the fully qualified Java class name described by this type.
 org.eclipse.emf.ecore.EClassifier getEClassifier()
          Return the Ecore EClassifier described by this type.
 java.lang.Class<?> getJavaClass()
          Return the basic Java class for this descriptor.
 TypeDescriptor getPrimitiveDescriptor()
          Return the type descriptor for use when a primitive type would be appropriate.
 UnboxedDescriptor getUnboxedDescriptor()
          Return the type descriptor for use when an unboxed type would be appropriate.
 java.lang.Class<?> hasJavaClass()
          Return the basic Java class for this descriptor.
 boolean isAssignableFrom(TypeDescriptor typeDescriptor)
          Return true if an instance described by typeDescriptor may be assigned to an instance described by this.
 boolean isAssignableTo(java.lang.Class<?> javaClass)
          Return true if an instance described by this typeDescriptor may be assigned to a javaClass.
 

Method Detail

append

void append(@NonNull
            JavaStream js)
Append the declaration of this type to a JavaStream. e.g. "typename"


appendBox

@NonNull
java.lang.Boolean appendBox(@NonNull
                                    JavaStream js,
                                    @NonNull
                                    JavaLocalContext localContext,
                                    @NonNull
                                    CGBoxExp cgBoxExp,
                                    @NonNull
                                    CGValuedElement unboxedValue)

appendCast

void appendCast(@NonNull
                JavaStream js,
                @Nullable
                java.lang.Class<?> actualJavaClass,
                @Nullable
                JavaStream.SubStream subStream)
Append the actualJavaClass subStream to js wrapped in a cast to this type.g. "(typename)subStream"


appendCastTerm

void appendCastTerm(@NonNull
                    JavaStream js,
                    @NonNull
                    CGValuedElement cgElement)
Append a cgElement to js wrapped in a cast to this type


appendNotEqualsTerm

void appendNotEqualsTerm(@NonNull
                         JavaStream js,
                         @NonNull
                         CGValuedElement thisValue,
                         @NonNull
                         TypeDescriptor thatTypeDescriptor,
                         @NonNull
                         java.lang.String thatName)
Append an expression term that evaluates whether (this TypedDescriptor and) thisValue is not equal to thatTypeDescriptor and thatName.


appendEqualsValue

void appendEqualsValue(@NonNull
                       JavaStream js,
                       @NonNull
                       CGValuedElement thisValue,
                       @NonNull
                       CGValuedElement thatValue,
                       boolean notEquals)
Append an expression term that evaluates whether (this TypedDescriptor and) thisValue is not equals/ notEquals to thatValue.
It is assumed that all the degenerate constant cases have been optimzed away.


appendUnboxStatements

@NonNull
java.lang.Boolean appendUnboxStatements(@NonNull
                                                JavaStream js,
                                                @NonNull
                                                JavaLocalContext localContext,
                                                @NonNull
                                                CGUnboxExp cgUnboxExp,
                                                @NonNull
                                                CGValuedElement boxedValue)

asCollectionDescriptor

@Nullable
CollectionDescriptor asCollectionDescriptor()
Return a non-null Collection type descriptor if this type descriptor dedescribes a Collection.

Returns:

getClassName

@NonNull
java.lang.String getClassName()
Return the fully qualified Java class name described by this type. In the case of collection types, this method returns the class name of the collection elements.


getEClassifier

@Nullable
org.eclipse.emf.ecore.EClassifier getEClassifier()
Return the Ecore EClassifier described by this type. In the case of collection types, this method returns the EClassifier of the collection elements. May return null when no EClssifier available.


getJavaClass

@NonNull
java.lang.Class<?> getJavaClass()
Return the basic Java class for this descriptor. e.g. List for an unboxed collection.


getPrimitiveDescriptor

@NonNull
TypeDescriptor getPrimitiveDescriptor()
Return the type descriptor for use when a primitive type would be appropriate. Returns this when there is no distinction for primitive types.


getUnboxedDescriptor

@NonNull
UnboxedDescriptor getUnboxedDescriptor()
Return the type descriptor for use when an unboxed type would be appropriate. Returns this when this is an unboxed descriptor.


hasJavaClass

@Nullable
java.lang.Class<?> hasJavaClass()
Return the basic Java class for this descriptor. e.g. List for an unboxed collection. Returns null for no Java class known.


isAssignableFrom

boolean isAssignableFrom(@NonNull
                         TypeDescriptor typeDescriptor)
Return true if an instance described by typeDescriptor may be assigned to an instance described by this.


isAssignableTo

boolean isAssignableTo(@NonNull
                       java.lang.Class<?> javaClass)
Return true if an instance described by this typeDescriptor may be assigned to a javaClass.