Class TypeQueries


  • public class TypeQueries
    extends java.lang.Object
    Provides some utility operations, also due to the split in the inheritance hierarchy.
    Author:
    Holger Eichelberger
    • Constructor Detail

      • TypeQueries

        public TypeQueries()
    • Method Detail

      • getOperation

        public static Operation getOperation​(IDatatype operand,
                                             java.lang.String name,
                                             IDatatype... parameter)
        Returns an operation defined on operand with given name and parameters. Please note that the first parameter of an operation is implicitly operand.
        Parameters:
        operand - the type the operation shall be defined for
        name - the name of the operation
        parameter - the list of parameters (excluding this data type)
        Returns:
        the operation or null if none was found
      • sameTypes

        public static boolean sameTypes​(IDatatype type1,
                                        IDatatype type2)
        Returns whether the two types given are the same.
        Parameters:
        type1 - the first type
        type2 - the second type
        Returns:
        true if type1 and type2 are the same, false else
      • isAnyType

        public static boolean isAnyType​(IDatatype type)
        Returns whether type is AnyType.
        Parameters:
        type - the type to check
        Returns:
        true for AnyType, false else
      • isEnum

        public static boolean isEnum​(IDatatype type)
        Returns whether type is an enum.
        Parameters:
        type - the type to check
        Returns:
        true if type is an enum, false else
      • isFreezeVariableType

        public static boolean isFreezeVariableType​(IDatatype type)
        Returns whether type is a freeze variable.
        Parameters:
        type - the type to check
        Returns:
        true if type is a a freeze variable, false else
      • isReference

        public static boolean isReference​(IDatatype type)
        Returns whether type is a reference.
        Parameters:
        type - the type to check
        Returns:
        true if type is a reference, false else
      • isConstraint

        public static boolean isConstraint​(IDatatype type)
        Returns whether type is a constraint (in the sense of a constraint variable).
        Parameters:
        type - the type to check
        Returns:
        true if type is a constraint, false else
      • isCompound

        public static boolean isCompound​(IDatatype type)
        Returns whether type is a compound type.
        Parameters:
        type - the type
        Returns:
        true for compound, false else
      • isContainer

        public static boolean isContainer​(IDatatype type)
        Returns whether type is a container.
        Parameters:
        type - the type to check for
        Returns:
        true if type is a container, false else
      • isSet

        public static boolean isSet​(IDatatype type)
        Returns whether type is a set.
        Parameters:
        type - the type to check for
        Returns:
        true if type is a container, false else
      • isSequence

        public static boolean isSequence​(IDatatype type)
        Returns whether type is a sequence.
        Parameters:
        type - the type to check for
        Returns:
        true if type is a container, false else
      • findDeepestGeneric

        public static IDatatype findDeepestGeneric​(IDatatype type,
                                                   int pos)
        Finds the deepest generic type in type always trying pos as position for the generic type.
        Parameters:
        type - the type
        pos - the 0-based position of the generic type to follow
        Returns:
        the deepest generic type
      • toGenerics

        public static IDatatype[] toGenerics​(IDatatype type)
        Turns the generics of type into an array of types.
        Parameters:
        type - the type
        Returns:
        the generics
      • resolveFully

        public static IDatatype resolveFully​(IDatatype type)
        Resolves to the most basic type, i.e., even across nested references/derived types.
        Parameters:
        type - the type to resolve
        Returns:
        the most basic type