## org.eclipse.ocl
Interface TypeChecker<C,O,P>

All Known Implementing Classes:
  AbstractTypeChecker

    public interface TypeChecker<C,O,P>

This optional interface is to be implemented by clients that want to add type checking capabilities to their `Environment`.

The `AbstractTypeChecker` provides the default implementation for the OCL type system. Rather than implement this interface, it is suggested that, if at al possible, clients extend the `AbstractTypeChecker` class, instead.

See the `Environment` interface for a description of the generic type parameters of this class. See the `AbstractTypeChecker` class for classes for implementation details.

Since:
  1.3
See Also:
  `AbstractTypeChecker`

Method Summary
`boolean` `checkMutuallyComparable(Object problemObject, C type1, C type2, int opcode)` Checks whether two types are mutually comparable in the determination of the applicability of = and <> operations.
`C` `commonSuperType(Object problemObject, C type1, C type2)` Get the common supertype of two types.
`boolean` `compatibleTypeMatch(C type1, C type2)` Compare two types.
`boolean` `exactTypeMatch(C type1, C type2)` Compare two types.
`P` `findAttribute(C owner, String name)` Finds the most specific (re)definition of an attribute in the specified classifier.
`O` `findOperationMatching(C owner, String name, List<? extends TypedElement<C>> args)` Finds an operation by signature in the specified classifier.
`C` `findSignalMatching(C receiver, List<C> signals, String name, List<? extends TypedElement<C>> args)` Find a matching signal in the specified list.
`List<P>` `getAttributes(C owner)` Obtains all of the OCL attributes applicable to the specified owner type, including any that were defined in the OCL environment as additional attributes.
`List<O>` `getOperations(C owner)` Obtains all of the OCL operations applicable to the specified owner type, including any that were defined in the OCL environment as additional operations.
`C` `getPropertyType(C owner, P property)` Gets the type of a property, accounting for the fact that we may be navigating to it from an association class (in which the member ends of an association always have multiplicity 1) or not.
`int` `getRelationship(C type1, C type2)` Queries the relationship, according to generalizations, of two types.
`C` `getResultType(Object problemObject, C owner, O operation, List<? extends TypedElement<C>> args)` Obtains the effective result type of the specified operation, which may or may not have parameters type by generic type variables.
`boolean` `isStandardLibraryFeature(C owner, Object feature)` Queries whether the specified feature (operation or attribute), as applied to a particular `owner` classifier, is defined by the standard library or not (in which case it would, presumably, be user-defined).
`boolean` `matchArgs(C owner, List<?> paramsOrProperties, List<? extends TypedElement<C>> args)` Compares an actual argument list against the signature of an operation or a signal.
`O` `resolveGenericSignature(C owner, O oper)` Resolves the signature of a generic operation (where it has parameters of type and/or `T` or `T2`) against the source type of the operation, as appropriate.

Method Detail

### getRelationship

    int getRelationship(C type1,
                        C type2)

  Queries the relationship, according to generalizations, of two types. This operation accounts for the OCL Standard Library types, which the otherwise similar `UMLReflection.getRelationship(Object, Object)` method does not.

  Parameters:
    `type1` - a type
    `type2` - another type
  Returns:
    the nature of their hierarchical relationship of `type1` to `type2`, as enumerated in the `UMLReflection` interface
  See Also:
    `UMLReflection.getRelationship(Object, Object)`

### getResultType

    C getResultType(Object problemObject,
                    C owner,
                    O operation,
                    List<? extends TypedElement<C>> args)

  Obtains the effective result type of the specified operation, which may or may not have parameters type by generic type variables. Many of the OCL Standard Library operations are either generic themselves or defined by generic types, so the return results depend on the argument and source types.

  Parameters:
    `problemObject` - the context object on which to report any problem that we may find in computing the result type. Usually this is some abstract or concrete syntax tree node
    `owner` - the owner of the operation (type on which the operation is called)
    `operation` - the operation signature
    `args` - the arguments of the operation call, which are expressions or variables
  Returns:
    the effective result type of the corresponding operation, or null after reporting a problem if any of the argument types do not correspond to the source type and/or expected parameter types of the operation

### getPropertyType

    C getPropertyType(C owner,
                      P property)

  Gets the type of a property, accounting for the fact that we may be navigating to it from an association class (in which the member ends of an association always have multiplicity 1) or not.

  Parameters:
    `owner` - the source of the navigation of the property, which may be an association class (the interesting scenario)
    `property` - the property to navigate
  Returns:
    the effective type of the property, which may not be a collection type despite its declared multiplicity in the association class case

### commonSuperType

    C commonSuperType(Object problemObject,
                      C type1,
                      C type2)

  Get the common supertype of two types. This operation accounts for the OCL Standard Library types, which the otherwise similar `UMLReflection.getCommonSuperType(Object, Object)` method does not.

  Parameters:
    `problemObject` - the object which could have problems.
    `type1` - a type
    `type2` - another type
  Returns:
    their common supertype, if any, null if the two types have no common supertype
  See Also:
    `UMLReflection.getCommonSuperType(Object, Object)`

### checkMutuallyComparable

    boolean checkMutuallyComparable(Object problemObject,
                                    C type1,
                                    C type2,
                                    int opcode)

  Checks whether two types are mutually comparable in the determination of the applicability of = and <> operations.

  Parameters:
    `problemObject` - the object which could have problems.
    `type1` - a type
    `type2` - another type
    `opcode` - the operation code
  Returns:
    false if the types are not comparable

### exactTypeMatch

    boolean exactTypeMatch(C type1,
                           C type2)

  Compare two types. Returns true if types are exactly equal, false otherwise.

  Parameters:
    `type1` - a type
    `type2` - another type
  Returns:
    true if the same type

### compatibleTypeMatch

    boolean compatibleTypeMatch(C type1,
                                C type2)

  Compare two types. Returns true if types are compatible, false otherwise.

  Parameters:
    `env` - the OCL environment
    `type1` - a type
    `type2` - another type
  Returns:
    true if the same type or type1 is a strict subtype of type2.

### getOperations

    List<O> getOperations(C owner)

  Obtains all of the OCL operations applicable to the specified owner type, including any that were defined in the OCL environment as additional operations.

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

### getAttributes

    List<P> getAttributes(C owner)

  Obtains all of the OCL attributes applicable to the specified owner type, including any that were defined in the OCL environment as additional attributes.

  Parameters:
    `owner` - the attribute owner type
  Returns:
    an unmodifiable list of its attributes

### resolveGenericSignature

    O resolveGenericSignature(C owner,
                              O oper)

  Resolves the signature of a generic operation (where it has parameters of type and/or `T` or `T2`) against the source type of the operation, as appropriate.

  Parameters:
    `owner` - the operation source type
    `oper` - the generic operation
  Returns:
    the resolved parameter type

### findSignalMatching

    C findSignalMatching(C receiver,
                         List<C> signals,
                         String name,
                         List<? extends TypedElement<C>> 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

### findOperationMatching

    O findOperationMatching(C owner,
                            String name,
                            List<? extends TypedElement<C>> args)

  Finds an operation by signature in the specified classifier.

  Parameters:
    `owner` - the classifier to search
    `name` - the name of the operation
    `args` - a list of arguments to match against the operation signature, as either expressions or variables
  Returns:
    the matching operation, or `null` if not found

### matchArgs

    boolean matchArgs(C owner,
                      List<?> paramsOrProperties,
                      List<? extends TypedElement<C>> args)

  Compares an actual argument list against the signature of an operation or a signal.

  Parameters:
    `owner` - the type that owns the operation
    `params` - the operation parameters or signal attributes to match against the arguments
    `args` - a list of `OCLExpression`s or `Variable`s
  Returns:
    true or false

### findAttribute

    P findAttribute(C owner,
                    String name)

  Finds the most specific (re)definition of an attribute in the specified classifier.

  Parameters:
    `env` - the OCL environment
    `owner` - the classifier to search
    `name` - the name of the operation
    `args` - a list of arguments to match against the operation signature, as either expressions or variables
  Returns:
    the matching operation, or `null` if not found

### isStandardLibraryFeature

    boolean isStandardLibraryFeature(C owner,
                                     Object feature)

  Queries whether the specified feature (operation or attribute), as applied to a particular `owner` classifier, is defined by the standard library or not (in which case it would, presumably, be user-defined).

  Parameters:
    `owner` - a classifier on which a feature is to be accessed
    `feature` - the feature to be accessed
  Returns:
    whether the feature is defined by the standard library

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