## org.eclipse.emf.ocl.types.impl
Class TypeUtil

    java.lang.Object
      org.eclipse.emf.ocl.types.impl.TypeUtil

    public class TypeUtil

extends Object

Static utilities for introspecting OCL types.

Method Summary
`static EClassifier` `commonSuperType(EClassifier type1, EClassifier type2)` Get the common supertype of two types.
`static EOperation` `defineOperation(EClassifier owner, String name, EList params, EClassifier type)`
`static EStructuralFeature` `defineProperty(EClassifier owner, Variable variable)`
`static EOperation` `findOperationMatching(EClassifier owner, String name, EList args)` Find the operation in the specified classifier
`static EClass` `findSignalMatching(EClassifier receiver, EList signals, String name, EList args)` Find a matching signal in the specified list.
`static EList` `getAdditionalOperations(EClassifier owner)`
`static EList` `getAdditionalProperties(EClassifier owner)`
`static EClassifier` `getOCLCollectionType(EClassifier type, boolean isOrdered, boolean isUnique)` Obtains the appropriate OCL collection type for an `EClassifier`, according to the collection's orderedness and uniqueness.
`static EClassifier` `getOCLType(EClassifier type)` Obtains the appropriate OCL type for an `EClassifier`, if it corresponds to an OCL primitive type.
`static EClassifier` `getOCLType(ETypedElement typedElement)` Obtains the appropriate OCL type for an Ecore typed element, according to its type, multiplicity, orderedness, and uniqueness.
`static EList` `getOperations(EClassifier owner)` Obtains all of the OCL operations applicable to the specified owner type.
`static EList` `getProperties(EClassifier owner)`
`static int` `getRelationship(EClassifier type1, EClassifier type2)` Computes the relationship between two types.
`static EClassifier` `getResultType(EClassifier owner, EOperation oper)`
`static boolean` `isMany(ETypedElement typedElement)` Custom is-many determination to assume that XSD unspecified multiplicities are many.
`static void` `resolveAdditionalFeatures(EClassifier owner, Environment env)`
`static EOperation` `resolveGenericSignature(EClassifier owner, EOperation oper)`
`static EClassifier` `resolveType(Environment env, EClassifier type)` Resolves the specified type against the model-based types defined by the specified environment's type resolver, for consistency with the environment (especially for persistence).
`static boolean` `type1AsType2(EClassifier type1, EClassifier type2)`
`static int` `typeCompare(EClassifier type1, EClassifier type2)` Compare 2 types.
`static void` `undefineAdditionalFeatures(EClassifier owner)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### findOperationMatching

    public static EOperation findOperationMatching(EClassifier owner,
                                                   String name,
                                                   EList args)

  Find the operation in the specified classifier

  Parameters:
    `owner` - EClassifier owning operations
    `name` - name of operation
    `args` - list of arguments to match against the operation signature
  Returns:
    the matching operation, or `null` if not found

### findSignalMatching

    public static EClass findSignalMatching(EClassifier receiver,
                                            EList signals,
                                            String name,
                                            EList args)

  Find a matching signal in the specified list.

  Parameters:
    `receiver` - the type that receives the signal
    `signals` - the signals to search
    `name` - name of signal to find
    `args` - list of arguments to match against the signal signature
  Returns:
    the matching signal, or `null` if not found

### getOperations

    public static EList getOperations(EClassifier owner)

  Obtains all of the OCL operations applicable to the specified owner type.

  Parameters:
    `owner` - the operation owner type
  Returns:
    an unmodifiable list of its operations

### getProperties

    public static EList getProperties(EClassifier owner)

### resolveGenericSignature

    public static EOperation resolveGenericSignature(EClassifier owner,
                                                     EOperation oper)

### getResultType

    public static EClassifier getResultType(EClassifier owner,
                                            EOperation oper)

### type1AsType2

    public static boolean type1AsType2(EClassifier type1,
                                       EClassifier type2)
                                throws SemanticException

  Throws:
    `SemanticException`

### typeCompare

    public static int typeCompare(EClassifier type1,
                                  EClassifier type2)

  Compare 2 types. Returns 0 if types are exactly equal, -1 if type1 conforms to type2 (type1 is a subtype of type2) 1 if type2 conforms to type1 (type2 is a subtype of type1) Throws an IllegalArgumentException if there is no type conformance.

  Parameters:
    `type1` - - EClassifier
    `type2` - - EClassifier
  Returns:
    the ordering key

### commonSuperType

    public static EClassifier commonSuperType(EClassifier type1,
                                              EClassifier type2)
                                       throws SemanticException

  Get the common supertype of two types.

  Parameters:
    `type1` -
    `type2` -
  Returns:
    the common supertype
  Throws:
    `SemanticException`

### getRelationship

    public static int getRelationship(EClassifier type1,
                                      EClassifier type2)

  Computes the relationship between two types.

  Parameters:
    `type1` - a type
    `type2` - another type
  Returns:
    either `PredefinedType.UNRELATED_TYPE`, `PredefinedType.STRICT_SUBTYPE`, `PredefinedType.STRICT_SUPERTYPE`, or `PredefinedType.SAME_TYPE` according to the relationship between the types

### getOCLType

    public static EClassifier getOCLType(ETypedElement typedElement)

  Obtains the appropriate OCL type for an Ecore typed element, according to its type, multiplicity, orderedness, and uniqueness. The mapping is as follows:
  - single-valued: EDataTypes map to corresponding OCL primitives where possible. Not a collection type
  - multi-valued: element type mapped to OCL primitives where possible. Overall type maps to a collection type:
    - ordered, unique: ordered set type
    - ordered, non-unique: sequence type
    - non-ordered, unique: set type
    - non-ordered, non-unique: bag type

  Parameters:
    `typedElement` - the ECore typed element to get the OCL type for
  Returns:
    the corresponding OCL type
  See Also:
    `getOCLType(EClassifier)`, `getOCLCollectionType(EClassifier, boolean, boolean)`

### getOCLType

    public static EClassifier getOCLType(EClassifier type)

  Obtains the appropriate OCL type for an `EClassifier`, if it corresponds to an OCL primitive type.

  Parameters:
    `type` - the type to convert to an OCL type
  Returns:
    the corresponding OCL type

### getOCLCollectionType

    public static EClassifier getOCLCollectionType(EClassifier type,
                                                   boolean isOrdered,
                                                   boolean isUnique)

  Obtains the appropriate OCL collection type for an `EClassifier`, according to the collection's orderedness and uniqueness. The mapping is as follows:
  - ordered, unique: ordered set type
  - ordered, non-unique: sequence type
  - non-ordered, unique: set type
  - non-ordered, non-unique: bag type

  Note that the collection's element `type` is mapped to an OCL primitive type where possible.

  Parameters:
    `type` - the type to get the corresponding OCL collection type for
    `isOrdered` - whether the OCL type should be ordered
    `isUnique` - whether the OCL type should be unique
  Returns:
    the corresponding OCL type
  See Also:
    `getOCLType(EClassifier)`

### isMany

    public static boolean isMany(ETypedElement typedElement)

  Custom is-many determination to assume that XSD unspecified multiplicities are many.

  Parameters:
    `typedElement` - a typed element
  Returns:
    whether it is not definitely a scalar

### resolveType

    public static EClassifier resolveType(Environment env,
                                          EClassifier type)

  Resolves the specified type against the model-based types defined by the specified environment's type resolver, for consistency with the environment (especially for persistence).

  Parameters:
    `env` - the parser environment
    `type` - the type to resolve
  Returns:
    the environment's corresponding type

### defineProperty

    public static EStructuralFeature defineProperty(EClassifier owner,
                                                    Variable variable)

### defineOperation

    public static EOperation defineOperation(EClassifier owner,
                                             String name,
                                             EList params,
                                             EClassifier type)

### getAdditionalProperties

    public static EList getAdditionalProperties(EClassifier owner)

### getAdditionalOperations

    public static EList getAdditionalOperations(EClassifier owner)

### undefineAdditionalFeatures

    public static void undefineAdditionalFeatures(EClassifier owner)

### resolveAdditionalFeatures

    public static void resolveAdditionalFeatures(EClassifier owner,
                                                 Environment env)

Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved.