Package de.gebit.integrity.utils

## Class IntegrityDSLUtil

- java.lang.Object
- - de.gebit.integrity.utils.IntegrityDSLUtil

-     public final class IntegrityDSLUtil
      extends Object

  A utility class providing various helper functions.
  Author:
    Rene Schneider - initial API and implementation

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static String` | `cleanMultiLineComment​(VisibleMultiLineComment aComment)` | Removes prefix and suffix from visible single-line comment text, as well as any newlines in between.
    `static String` | `cleanSingleLineComment​(VisibleSingleLineComment aComment)` | Removes the prefix as well as any trailing newlines from visible single-line comment text.
    `static void` | `ensureResolved​(org.eclipse.emf.ecore.EObject anObject)` | Ensures that a given EObject that is possibly a proxy is resolved, resolving it if necessary.
    `static VariableOrConstantEntity` | `extractVariableOrConstantEntity​(ValueOrEnumValueOrOperation anInput)` | Attempts to extract a `VariableOrConstantEntity` from the provided `ValueOrEnumValueOrOperation`.
    `static <T extends org.eclipse.emf.ecore.EObject> T` | `findUpstreamContainer​(Class<T> aContainerClass, org.eclipse.emf.ecore.EObject aSource)` | Finds an upstream container matching a provided container class.
    `static List<org.eclipse.xtext.common.types.JvmEnumerationLiteral>` | `getAllEnumLiteralsFromFixtureMethodParam​(MethodReference aMethod, org.eclipse.xtext.common.types.JvmAnnotationReference aParamAnnotation)` | Returns a list of all valid enumeration literals for a given parameter in a given fixture method.
    `static List<ParamAnnotationTypeTriplet>` | `getAllParamNamesFromFixtureMethod​(MethodReference aMethod)` | Returns a list of all defined parameter names in a given fixture method, each of the results linked to the annotation reference that's connected to the parameter in the method signature.
    `static List<ParamAnnotationTypeTriplet>` | `getAllParamNamesFromFork​(ForkDefinition aFork)` | Returns a list of all defined parameter names in a given fork, each of the results linked to the annotation reference that's connected to the parameter in the constructor signature.
    `static List<ParamAnnotationTypeTriplet>` | `getAllParamNamesFromForkerClass​(org.eclipse.xtext.common.types.JvmGenericType aForkerType)` | Returns a list of all defined parameter names in a given forker class, each of the results linked to the annotation reference that's connected to the parameter in the constructor signature.
    `static List<ResultFieldTuple>` | `getAllResultNamesFromFixtureMethod​(MethodReference aMethod)` | Returns a list of named results defined by a given fixture method.
    `static Collection<ValueOrEnumValueOrOperation>` | `getAllValuesFromCollection​(ValueOrEnumValueOrOperationCollection aValueCollection)` | Aggregates all `ValueOrEnumValueOrOperation`s from the given `ValueOrEnumValueOrOperationCollection`. Integrity has (historically; could be done more elegant with todays' Xtext) splitted `ValueOrEnumValueOrOperationCollection`s' internal values into two properties: a single value comes from `ValueOrEnumValueOrOperationCollection.getValue()` and everything else goes into `ValueOrEnumValueOrOperationCollection.getMoreValues()`.
    `static String` | `getExpectedResultNameStringFromTestResultName​(ResultName aName)` | Returns the name of a specific test result value.
    `static String` | `getIdentifierFromArbitraryParameterOrResultName​(ArbitraryParameterOrResultName aName)` | `ArbitraryParameterOrResultName`s can be identified either by a free-form String (enclosed in quotes) or by a more restricted ID (without quotes).
    `static String` | `getIdentifierFromKeyValuePair​(KeyValuePair aPair)` | `KeyValuePair`s can be identified either by a free-form String (enclosed in quotes) or by a more restricted ID (without quotes).
    `static ValueOrEnumValueOrOperationCollection` | `getInitialValueForConstant​(ConstantDefinition aConstant, VariantDefinition aVariant)` | Determines the initial value for the given constant.
    `static ValueOrEnumValueOrOperationCollection` | `getInitialValueForVariableOrConstantEntity​(VariableOrConstantEntity anEntity, VariantDefinition aVariant)` | Determines the initial value to use for the given `VariableOrConstantEntity`.
    `static MethodReference` | `getMethodReferenceForAction​(org.eclipse.emf.ecore.EObject anAction)` | Finds the matching method reference for a given `Test`, `Call` or `TableTest`.
    `static PackageDefinition` | `getPackageContaining​(org.eclipse.emf.ecore.EObject anObject)` | Finds the `PackageDefinition` that contains the given `EObject`.
    `static boolean` | `getParamMandatoryFlagFromAnnotation​(org.eclipse.xtext.common.types.JvmAnnotationReference anAnnotation)` | Returns whether the mandatory flag is set defined by a given annotation reference.
    `static String` | `getParamNameFromAnnotation​(org.eclipse.xtext.common.types.JvmAnnotationReference anAnnotation)` | Returns the name of a single parameter defined by a given annotation reference.
    `static String` | `getParamNameStringFromParameterName​(ParameterName aParameterName)` | Returns the name of a single given parameter defined by a `ParameterName` instance.
    `static String` | `getQualifiedCallName​(CallDefinition aCall)` | Returns the fully qualified name of a given `CallDefinition`.
    `static String` | `getQualifiedForkName​(ForkDefinition aFork)` | Returns the fully qualified name of a given `ForkDefinition`.
    `static String` | `getQualifiedNameOfFixtureMethod​(MethodReference aReference)` | Returns the fully qualified name of the fixture method referenced by the given method reference.
    `static String` | `getQualifiedSuiteName​(SuiteDefinition aSuite)` | Returns the fully qualified name of a given `SuiteDefinition`.
    `static String` | `getQualifiedTestName​(TestDefinition aTest)` | Returns the fully qualified name of a given `TestDefinition`.
    `static String` | `getQualifiedVariableEntityName​(VariableOrConstantEntity aVariable, boolean aQualifyLocalVariables)` | Returns the fully qualified name of the given `VariableOrConstantEntity`.
    `static String` | `getQualifiedVariantName​(VariantDefinition aVariant)` | Returns the fully qualified name of a given `VariantDefinition`.
    `static ValueOrEnumValueOrOperation` | `getSpecificValueFromCollection​(ValueOrEnumValueOrOperationCollection aValueCollection, int anIndex)` | Gets a specific index position out of a `ValueOrEnumValueOrOperationCollection`.
    `static SuiteDefinition` | `getSuiteContaining​(org.eclipse.emf.ecore.EObject anObject)` | Finds the `SuiteDefinition` that contains the given `EObject`.
    `static String` | `getSuiteTitle​(SuiteDefinition aSuite)` | Gets the suites' title from a given suite.
    `static org.eclipse.emf.ecore.EObject` | `getTableHeaderForTableCell​(ParameterTableValue aTableCell)` | Finds the corresponding table header element to a given table cell element.
    `static Map<ParameterTableHeader,​List<ParameterTableValue>>` | `getTableParameterValuesPerParameter​(TableTest aTableTest)` | Returns a map of all `ParameterTableHeader`s in a given `TableTest` with their associated `ParameterTableValue`s.
    `static boolean` | `isGlobalVariableOrConstant​(VariableOrConstantEntity anEntity)` | Checks whether the given variable/constant entity is defined in a global (package) context.
    `static boolean` | `isPrivate​(org.eclipse.emf.ecore.EObject anObject)` | Checks whether the given `EObject` is of private visibility.
    `static boolean` | `isPrivateInsideSuite​(org.eclipse.emf.ecore.EObject anObject)` | Checks whether the given `EObject` is located inside a suite and is thus of private visibility by default.
    `static Boolean` | `isResult​(org.eclipse.emf.ecore.EObject anObject)` | Determines whether a given `EObject` is part of a result of a test/call/tabletest.

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

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

- - ### Method Detail

    - #### getAllParamNamesFromFixtureMethod

          public static List<ParamAnnotationTypeTriplet> getAllParamNamesFromFixtureMethod​(MethodReference aMethod)

      Returns a list of all defined parameter names in a given fixture method, each of the results linked to the annotation reference that's connected to the parameter in the method signature.
      Parameters:
        `aMethod` - the method to inspect
      Returns:
        a list of parameters and annotation references

    - #### getParamNameFromAnnotation

          public static String getParamNameFromAnnotation​(org.eclipse.xtext.common.types.JvmAnnotationReference anAnnotation)

      Returns the name of a single parameter defined by a given annotation reference.
      Parameters:
        `anAnnotation` - the annotation reference
      Returns:
        the name

    - #### getParamMandatoryFlagFromAnnotation

          public static boolean getParamMandatoryFlagFromAnnotation​(org.eclipse.xtext.common.types.JvmAnnotationReference anAnnotation)

      Returns whether the mandatory flag is set defined by a given annotation reference.
      Parameters:
        `anAnnotation` - the annotation reference
      Returns:
        true if mandatory, false otherwise

    - #### getAllParamNamesFromFork

          public static List<ParamAnnotationTypeTriplet> getAllParamNamesFromFork​(ForkDefinition aFork)

      Returns a list of all defined parameter names in a given fork, each of the results linked to the annotation reference that's connected to the parameter in the constructor signature. Only one constructor is supported.
      Parameters:
        `aFork` - the fork to inspect
      Returns:
        a list of parameters and annotation references

    - #### getAllParamNamesFromForkerClass

          public static List<ParamAnnotationTypeTriplet> getAllParamNamesFromForkerClass​(org.eclipse.xtext.common.types.JvmGenericType aForkerType)

      Returns a list of all defined parameter names in a given forker class, each of the results linked to the annotation reference that's connected to the parameter in the constructor signature. Only one constructor is supported.
      Parameters:
        `aForkerType` - the forker class to inspect
      Returns:
        a list of parameters and annotation references

    - #### getParamNameStringFromParameterName

          public static String getParamNameStringFromParameterName​(ParameterName aParameterName)

      Returns the name of a single given parameter defined by a `ParameterName` instance.
      Parameters:
        `aParameterName` - the parameter name instance
      Returns:
        the parameter name string

    - #### getAllEnumLiteralsFromFixtureMethodParam

          public static List<org.eclipse.xtext.common.types.JvmEnumerationLiteral> getAllEnumLiteralsFromFixtureMethodParam​(MethodReference aMethod,
                                                                                                                            org.eclipse.xtext.common.types.JvmAnnotationReference aParamAnnotation)

      Returns a list of all valid enumeration literals for a given parameter in a given fixture method.
      Parameters:
        `aMethod` - the fixture method reference
        `aParamAnnotation` - the parameter annotation reference
      Returns:
        a list of enumeration literals, or null if the parameter is not an enum parameter

    - #### getAllResultNamesFromFixtureMethod

          public static List<ResultFieldTuple> getAllResultNamesFromFixtureMethod​(MethodReference aMethod)

      Returns a list of named results defined by a given fixture method.
      Parameters:
        `aMethod` - the method
      Returns:
        the list of results

    - #### getQualifiedNameOfFixtureMethod

          public static String getQualifiedNameOfFixtureMethod​(MethodReference aReference)

      Returns the fully qualified name of the fixture method referenced by the given method reference.
      Parameters:
        `aReference` - the method reference
      Returns:
        the fully qualified name, including the name of the class and the method itself

    - #### getQualifiedSuiteName

          public static String getQualifiedSuiteName​(SuiteDefinition aSuite)

      Returns the fully qualified name of a given `SuiteDefinition`.
      Parameters:
        `aSuite` - the suite
      Returns:
        the fully qualified name

    - #### getQualifiedVariantName

          public static String getQualifiedVariantName​(VariantDefinition aVariant)

      Returns the fully qualified name of a given `VariantDefinition`.
      Parameters:
        `aVariant` - the variant
      Returns:
        the fully qualified name

    - #### getQualifiedForkName

          public static String getQualifiedForkName​(ForkDefinition aFork)

      Returns the fully qualified name of a given `ForkDefinition`.
      Parameters:
        `aFork` - the fork
      Returns:
        the fully qualified name

    - #### getQualifiedCallName

          public static String getQualifiedCallName​(CallDefinition aCall)

      Returns the fully qualified name of a given `CallDefinition`.
      Parameters:
        `aCall` - the call definition
      Returns:
        the fully qualified name

    - #### getQualifiedTestName

          public static String getQualifiedTestName​(TestDefinition aTest)

      Returns the fully qualified name of a given `TestDefinition`.
      Parameters:
        `aTest` - the test definition
      Returns:
        the fully qualified name

    - #### getQualifiedVariableEntityName

          public static String getQualifiedVariableEntityName​(VariableOrConstantEntity aVariable,
                                                              boolean aQualifyLocalVariables)

      Returns the fully qualified name of the given `VariableOrConstantEntity`.
      Parameters:
        `aVariable` - the variable
      Returns:
        the fully qualified name

    - #### getExpectedResultNameStringFromTestResultName

          public static String getExpectedResultNameStringFromTestResultName​(ResultName aName)

      Returns the name of a specific test result value.
      Parameters:
        `aName` - the result name object
      Returns:
        the name string

    - #### cleanSingleLineComment

          public static String cleanSingleLineComment​(VisibleSingleLineComment aComment)

      Removes the prefix as well as any trailing newlines from visible single-line comment text.
      Parameters:
        `aComment` - the comment
      Returns:
        the cleaned text

    - #### cleanMultiLineComment

          public static String cleanMultiLineComment​(VisibleMultiLineComment aComment)

      Removes prefix and suffix from visible single-line comment text, as well as any newlines in between.
      Parameters:
        `aComment` - the comment
      Returns:
        the cleaned text

    - #### getSuiteTitle

          public static String getSuiteTitle​(SuiteDefinition aSuite)

      Gets the suites' title from a given suite.
      Parameters:
        `aSuite` - the suite to search in
      Returns:
        the title of the suite or null if it does not have one

    - #### isResult

          public static Boolean isResult​(org.eclipse.emf.ecore.EObject anObject)

      Determines whether a given `EObject` is part of a result of a test/call/tabletest.
      Parameters:
        `anObject` - the object to look at
      Returns:
        true if it is a result, false if not. Null if not determinable.

    - #### getTableHeaderForTableCell

          public static org.eclipse.emf.ecore.EObject getTableHeaderForTableCell​(ParameterTableValue aTableCell)

      Finds the corresponding table header element to a given table cell element.
      Parameters:
        `aTableCell` - the table cell element
      Returns:
        the table header element if one exists, the table itself in case of the default result column or null if nothing was found

    - #### getTableParameterValuesPerParameter

          public static Map<ParameterTableHeader,​List<ParameterTableValue>> getTableParameterValuesPerParameter​(TableTest aTableTest)

      Returns a map of all `ParameterTableHeader`s in a given `TableTest` with their associated `ParameterTableValue`s.
      Parameters:
        `aTableTest` - the table test to map
      Returns:
        all parameter columns with their associated values

    - #### getMethodReferenceForAction

          public static MethodReference getMethodReferenceForAction​(org.eclipse.emf.ecore.EObject anAction)

      Finds the matching method reference for a given `Test`, `Call` or `TableTest`.
      Parameters:
        `anAction` - the action to find a method for
      Returns:
        the method or null if none was found

    - #### getInitialValueForVariableOrConstantEntity

          public static ValueOrEnumValueOrOperationCollection getInitialValueForVariableOrConstantEntity​(VariableOrConstantEntity anEntity,
                                                                                                         VariantDefinition aVariant)

      Determines the initial value to use for the given `VariableOrConstantEntity`.
      Parameters:
        `anEntity` - the entity to explore
        `aVariant` - the current variant being executed (null if no variant is used)
      Returns:
        the initial value, or null if none was given

    - #### getInitialValueForConstant

          public static ValueOrEnumValueOrOperationCollection getInitialValueForConstant​(ConstantDefinition aConstant,
                                                                                         VariantDefinition aVariant)

      Determines the initial value for the given constant.
      Parameters:
        `aConstant` - the constant to explore
        `aVariant` - the current variant being executed (null if no variant is used)
      Returns:
        the initial value, or null if none was given

    - #### getAllValuesFromCollection

          public static Collection<ValueOrEnumValueOrOperation> getAllValuesFromCollection​(ValueOrEnumValueOrOperationCollection aValueCollection)

      Aggregates all `ValueOrEnumValueOrOperation`s from the given `ValueOrEnumValueOrOperationCollection`.
      Integrity has (historically; could be done more elegant with todays' Xtext) splitted `ValueOrEnumValueOrOperationCollection`s' internal values into two properties: a single value comes from `ValueOrEnumValueOrOperationCollection.getValue()` and everything else goes into `ValueOrEnumValueOrOperationCollection.getMoreValues()`. This method helps handling these by merging all the values into a single `Collection`.
      Parameters:
        `aValueCollection` - the value collection to aggregate single values from
      Returns:
        all the aggregated values in a single `Collection`.

    - #### getSpecificValueFromCollection

          public static ValueOrEnumValueOrOperation getSpecificValueFromCollection​(ValueOrEnumValueOrOperationCollection aValueCollection,
                                                                                   int anIndex)

      Gets a specific index position out of a `ValueOrEnumValueOrOperationCollection`.
      Parameters:
        `aValueCollection` - the value collection
        `anIndex` - the index to get
      Returns:
        the value

    - #### isGlobalVariableOrConstant

          public static boolean isGlobalVariableOrConstant​(VariableOrConstantEntity anEntity)

      Checks whether the given variable/constant entity is defined in a global (package) context.
      Parameters:
        `anEntity` - the entity to check
      Returns:
        true if globally defined, false if defined in a suite

    - #### findUpstreamContainer

          public static <T extends org.eclipse.emf.ecore.EObject> T findUpstreamContainer​(Class<T> aContainerClass,
                                                                                          org.eclipse.emf.ecore.EObject aSource)

      Finds an upstream container matching a provided container class.
      Parameters:
        `aContainerClass` - the class to find
        `aSource` - the starting point for the search
      Returns:
        the upstream container, or null if nothing was found

    - #### getPackageContaining

          public static PackageDefinition getPackageContaining​(org.eclipse.emf.ecore.EObject anObject)

      Finds the `PackageDefinition` that contains the given `EObject`.
      Parameters:
        `anObject` - the entity
      Returns:
        the package containing the entity, or null if the entity is not in a package

    - #### getSuiteContaining

          public static SuiteDefinition getSuiteContaining​(org.eclipse.emf.ecore.EObject anObject)

      Finds the `SuiteDefinition` that contains the given `EObject`.
      Parameters:
        `anObject` - the entity
      Returns:
        the suite containing the entity, or null if the entity is not in a package

    - #### getIdentifierFromKeyValuePair

          public static String getIdentifierFromKeyValuePair​(KeyValuePair aPair)

      `KeyValuePair`s can be identified either by a free-form String (enclosed in quotes) or by a more restricted ID (without quotes). This method abstracts aways the decision where to get the final identifier from.
      Parameters:
        `aPair` - the key-value pair
      Returns:
        the identifier

    - #### getIdentifierFromArbitraryParameterOrResultName

          public static String getIdentifierFromArbitraryParameterOrResultName​(ArbitraryParameterOrResultName aName)

      `ArbitraryParameterOrResultName`s can be identified either by a free-form String (enclosed in quotes) or by a more restricted ID (without quotes). This method abstracts aways the decision where to get the final identifier from.
      Parameters:
        `aName` - the name
      Returns:
        the identifier

    - #### isPrivate

          public static boolean isPrivate​(org.eclipse.emf.ecore.EObject anObject)

      Checks whether the given `EObject` is of private visibility.
      Parameters:
        `anObject` - the object to check
      Returns:
        true or false (will return false on objects which don't support a visibility modifier)

    - #### isPrivateInsideSuite

          public static boolean isPrivateInsideSuite​(org.eclipse.emf.ecore.EObject anObject)

      Checks whether the given `EObject` is located inside a suite and is thus of private visibility by default.
      Parameters:
        `anObject` -
      Returns:

    - #### extractVariableOrConstantEntity

          public static VariableOrConstantEntity extractVariableOrConstantEntity​(ValueOrEnumValueOrOperation anInput)

      Attempts to extract a `VariableOrConstantEntity` from the provided `ValueOrEnumValueOrOperation`.
      Parameters:
        `anInput` - the input value
      Returns:
        the entity if one is found, null if the input value was something else

    - #### ensureResolved

          public static void ensureResolved​(org.eclipse.emf.ecore.EObject anObject)

      Ensures that a given EObject that is possibly a proxy is resolved, resolving it if necessary.
      Parameters:
        `anObject` -