org.eclipse.viatra.query.patternlanguage.emf.types

## Class EMFTypeSystem

- java.lang.Object
- - org.eclipse.viatra.query.patternlanguage.emf.types.AbstractTypeSystem
  - - org.eclipse.viatra.query.patternlanguage.emf.types.EMFTypeSystem

- All Implemented Interfaces:
    ITypeSystem

      public class EMFTypeSystem
      extends AbstractTypeSystem

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EMFTypeSystem(org.apache.log4j.Logger logger)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.Set<IInputKey>` | `addTypeInformation(java.util.Set<IInputKey> types, IInputKey newType)` Adds a new type descriptor to a collection of type descriptors, and minimizes it.
    `java.util.Set<IInputKey>` | `addTypeInformation(java.util.Set<IInputKey> types, java.util.Set<IInputKey> newTypes)`
    `IInputKey` | `classifierToInputKey(org.eclipse.emf.ecore.EClassifier classifier)`
    `Type` | `convertToVQLType(org.eclipse.emf.ecore.EObject context, IInputKey key, boolean avoidDataTypes)` Returns a new Type instance that represents the same type as the parameter input key.
    `static org.eclipse.emf.ecore.EClassifier` | `extractClassifierFromInputKey(IInputKey key)` This function can be used to extract EClassifier instances from IInputKey instances.
    `static org.eclipse.emf.ecore.EClassifier` | `extractClassifierFromType(Type typeDeclaration)` This function can be used to extract EClassifier instances from Type declaration.
    `IInputKey` | `extractColumnDescriptor(RelationType type, int columnIndex)` Extracts the model-specific column type of the given index from a RelationType declaration
    `IInputKey` | `extractTypeDescriptor(Type type)` Extracts the model-specific types from a Type declaration.
    `java.util.Set<IInputKey>` | `getCompatibleSupertypes(java.util.Set<IInputKey> types)` Returns a set of types that is a common supertype of a set of type parameters
    `java.lang.Class<?>` | `getJavaClass(EDataTypeInSlotsKey key)`
    `java.lang.Class<?>` | `getJavaClass(JavaTransitiveInstancesKey javaKey)`
    `java.lang.String` | `getJavaClassName(EDataTypeInSlotsKey key)`
    `boolean` | `hasCommonSubtype(java.util.Set<IInputKey> typeKeys, java.lang.Iterable<org.eclipse.emf.ecore.EPackage> ePackages)`
    `java.util.Optional<org.eclipse.emf.ecore.EClassifier>` | `inputKeyToClassifier(IInputKey key)` Returns the EClassifier stored in the IInputKey.
    `boolean` | `isConformant(ClassType expectedType, ClassType actualType)`
    `boolean` | `isConformant(IInputKey expectedType, IInputKey actualType)` Decides whether the second type is compatible with the first one
    `boolean` | `isConformToRelationColumn(IInputKey relationType, int columnIndex, IInputKey columnType)` Decides whether the reference can have a selected type at its given column.
    `boolean` | `isConformToRelationSource(ReferenceType relationType, ClassType sourceType)`
    `boolean` | `isConformToRelationTarget(ReferenceType relationType, ClassType targetType)`
    `boolean` | `isValidType(Type type)` Returns whether the type declaration represents a valid, resolvable type for the selected type system.
    `java.util.Set<IInputKey>` | `minimizeTypeInformation(java.util.Set<IInputKey> types, boolean mergeWithSupertypes)` Reduces the type descriptor set by providing the most specific set of type descriptors inferrable for a selected types.
    `org.eclipse.xtext.common.types.JvmTypeReference` | `toJvmTypeReference(IInputKey type, org.eclipse.emf.ecore.EObject context)` Creates a type reference for model inference from a selected type.
    `java.lang.String` | `typeString(IInputKey type)` Converts a type object to a user-visible description string.

    - ### Methods inherited from class org.eclipse.viatra.query.patternlanguage.emf.types.AbstractTypeSystem

      `getWrapperClassForType, getWrapperClassNameForTypeName, isValidType`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.viatra.query.patternlanguage.emf.types.ITypeSystem

      `convertToVQLType`

- - ### Constructor Detail

    - #### EMFTypeSystem

          @Inject
          public EMFTypeSystem(org.apache.log4j.Logger logger)

  - ### Method Detail

    - #### extractClassifierFromInputKey

          public static org.eclipse.emf.ecore.EClassifier extractClassifierFromInputKey(IInputKey key)

      This function can be used to extract EClassifier instances from IInputKey instances. If the IInputKey instance does not represent an EClassifier, null is returned
      Since:
        2.0

    - #### extractClassifierFromType

          public static org.eclipse.emf.ecore.EClassifier extractClassifierFromType(Type typeDeclaration)

      This function can be used to extract EClassifier instances from Type declaration. If the IInputKey instance does not represent an EClassifier, null is returned
      Since:
        2.0

    - #### extractTypeDescriptor

          public IInputKey extractTypeDescriptor(Type type)

      Description copied from interface: `ITypeSystem`
      Extracts the model-specific types from a Type declaration.
      Parameters:
        `type` - either the `Type` or the `RelationType` instance
      Returns:
        model-specific type representation

    - #### convertToVQLType

          public Type convertToVQLType(org.eclipse.emf.ecore.EObject context,
                                       IInputKey key,
                                       boolean avoidDataTypes)

      Description copied from interface: `ITypeSystem`
      Returns a new Type instance that represents the same type as the parameter input key. Each call of this method will return a new instance, and the returned type is not contained in any other EMF object, making the return type safe to include in VQL models. Not all concrete IInputKey instances are supported by this method; in case of unsupported type an `IllegalArgumentException` will be thrown.
        `avoidDataTypes` - If set to true, data type are returned as Java types

    - #### classifierToInputKey

          public IInputKey classifierToInputKey(org.eclipse.emf.ecore.EClassifier classifier)

    - #### inputKeyToClassifier

          public java.util.Optional<org.eclipse.emf.ecore.EClassifier> inputKeyToClassifier(IInputKey key)

      Returns the EClassifier stored in the IInputKey. If no EClassifier is represented in the key, the optional will be empty.
      Since:
        2.0

    - #### extractColumnDescriptor

          public IInputKey extractColumnDescriptor(RelationType type,
                                                   int columnIndex)

      Description copied from interface: `ITypeSystem`
      Extracts the model-specific column type of the given index from a RelationType declaration

    - #### isConformant

          public boolean isConformant(IInputKey expectedType,
                                      IInputKey actualType)

      Description copied from interface: `ITypeSystem`
      Decides whether the second type is compatible with the first one

    - #### getJavaClass

          public java.lang.Class<?> getJavaClass(EDataTypeInSlotsKey key)

      Since:
        1.5

    - #### getJavaClassName

          public java.lang.String getJavaClassName(EDataTypeInSlotsKey key)

      Since:
        2.1

    - #### getJavaClass

          public java.lang.Class<?> getJavaClass(JavaTransitiveInstancesKey javaKey)

      Since:
        1.5

    - #### isConformant

          public boolean isConformant(ClassType expectedType,
                                      ClassType actualType)

      Since:
        2.0

    - #### isConformToRelationColumn

          public boolean isConformToRelationColumn(IInputKey relationType,
                                                   int columnIndex,
                                                   IInputKey columnType)

      Description copied from interface: `ITypeSystem`
      Decides whether the reference can have a selected type at its given column.

    - #### isConformToRelationSource

          public boolean isConformToRelationSource(ReferenceType relationType,
                                                   ClassType sourceType)

      Since:
        2.0

    - #### isConformToRelationTarget

          public boolean isConformToRelationTarget(ReferenceType relationType,
                                                   ClassType targetType)

      Since:
        2.0

    - #### toJvmTypeReference

          public org.eclipse.xtext.common.types.JvmTypeReference toJvmTypeReference(IInputKey type,
                                                                                    org.eclipse.emf.ecore.EObject context)

      Description copied from interface: `ITypeSystem`
      Creates a type reference for model inference from a selected type.

    - #### minimizeTypeInformation

          public java.util.Set<IInputKey> minimizeTypeInformation(java.util.Set<IInputKey> types,
                                                                  boolean mergeWithSupertypes)

      Description copied from interface: `ITypeSystem`
      Reduces the type descriptor set by providing the most specific set of type descriptors inferrable for a selected types.
      Parameters:
        `types` - a collection of type definitions
        `mergeWithSupertypes` - if true, the collection is also minimized by calculating common supertypes
      Returns:
        the minimized set of type information
      Since:
        1.3

    - #### addTypeInformation

          public java.util.Set<IInputKey> addTypeInformation(java.util.Set<IInputKey> types,
                                                             IInputKey newType)

      Description copied from interface: `ITypeSystem`
      Adds a new type descriptor to a collection of type descriptors, and minimizes it. Equivalent of calling `#minimizeTypeInformation(Set)` with `types.add(newType)`, but might have a more efficient impementation.
      Returns:
        the minimized set of type information including the new type descriptor key
      Since:
        1.3

    - #### addTypeInformation

          public java.util.Set<IInputKey> addTypeInformation(java.util.Set<IInputKey> types,
                                                             java.util.Set<IInputKey> newTypes)

      Since:
        1.3

    - #### hasCommonSubtype

          public boolean hasCommonSubtype(java.util.Set<IInputKey> typeKeys,
                                          java.lang.Iterable<org.eclipse.emf.ecore.EPackage> ePackages)

      Returns:
        True if the given classifiers has a common subtype in the selected EPackages.
      Since:
        1.3

    - #### typeString

          public java.lang.String typeString(IInputKey type)

      Description copied from interface: `ITypeSystem`
      Converts a type object to a user-visible description string.
      Specified by:
        `typeString` in interface `ITypeSystem`
      Overrides:
        `typeString` in class `AbstractTypeSystem`
      Parameters:
        `type` - either a `Type`, or a model-specific type instance
      Returns:
        the string representation of the selected type

    - #### getCompatibleSupertypes

          public java.util.Set<IInputKey> getCompatibleSupertypes(java.util.Set<IInputKey> types)

      Description copied from interface: `ITypeSystem`
      Returns a set of types that is a common supertype of a set of type parameters
      Since:
        1.3

    - #### isValidType

          public boolean isValidType(Type type)

      Description copied from interface: `ITypeSystem`
      Returns whether the type declaration represents a valid, resolvable type for the selected type system. A null type is invalid.
      Specified by:
        `isValidType` in interface `ITypeSystem`
      Overrides:
        `isValidType` in class `AbstractTypeSystem`