Class TypeHelper


  • public class TypeHelper
    extends java.lang.Object
    Generic type operations.
    Author:
    Holger Eichelberger
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TypeHelper()
      Prevents external instantiation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static IMetaOperation findConversion​(IMetaType argType, IMetaType paramType)
      Tries to find a conversion among the given types.
      static <O extends IMetaOperation>
      O
      getMoreSpecificParam1​(O op1, O op2)
      Returns the more specific operation based on the first parameter.
      static <T extends java.lang.annotation.Annotation>
      T
      getParameterAnnotation​(java.lang.annotation.Annotation[][] annotations, int index, java.lang.Class<T> cls)
      Returns the QM generic annotation if defined.
      static boolean isBasicType​(java.lang.Class<?> cls)
      Returns whether the given cls represents a basic type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TypeHelper

        private TypeHelper()
        Prevents external instantiation.
    • Method Detail

      • getMoreSpecificParam1

        public static final <O extends IMetaOperation> O getMoreSpecificParam1​(O op1,
                                                                               O op2)
        Returns the more specific operation based on the first parameter.
        Type Parameters:
        O - the type of the operation class
        Parameters:
        op1 - the first operation
        op2 - the second operation
        Returns:
        • op1 if the type of the first parameter of op1 is more specific than the type of the first parameter of op2
        • op2 if the type of the first parameter of op2 is more specific than the type of the first parameter of op1
        • op1 if the type of the first parameter of op1 is not a basic type while the first parameter of op2 is a basic type
        • op2 if the type of the first parameter of op2 is not a basic type while the first parameter of op1 is a basic type
        • op2 if op1 is null
        • op1 if op2 is null
        • op1 in any other case
      • findConversion

        public static IMetaOperation findConversion​(IMetaType argType,
                                                    IMetaType paramType)
        Tries to find a conversion among the given types. Defined conversions on both types are taken into account.
        Parameters:
        argType - the argument type
        paramType - the parameter type
        Returns:
        the conversion operation or null if there is none
      • isBasicType

        public static boolean isBasicType​(java.lang.Class<?> cls)
        Returns whether the given cls represents a basic type.
        Parameters:
        cls - the class to be tested
        Returns:
        true if cls represents a basic type, false else
      • getParameterAnnotation

        public static <T extends java.lang.annotation.Annotation> T getParameterAnnotation​(java.lang.annotation.Annotation[][] annotations,
                                                                                           int index,
                                                                                           java.lang.Class<T> cls)
        Returns the QM generic annotation if defined.
        Type Parameters:
        T - the annotation type to search for
        Parameters:
        annotations - the parameter annotations to consider
        index - the index of the parameter
        cls - the annotation class to return
        Returns:
        the annotation or null