Class MethodSelector

    • Constructor Summary

      Constructors 
      Constructor Description
      MethodSelector​(java.lang.Class<?> javaClass, java.lang.reflect.Method method)  
      MethodSelector​(java.lang.Class<?> javaClass, java.lang.String methodName, java.lang.Class<?>... parameterTypes)  
      MethodSelector​(java.lang.Class<?> javaClass, java.lang.String methodName, java.lang.String parameterTypeNames)  
      MethodSelector​(java.lang.ClassLoader classLoader, java.lang.String className, java.lang.String methodName, java.lang.Class<?>... parameterTypes)  
      MethodSelector​(java.lang.ClassLoader classLoader, java.lang.String className, java.lang.String methodName, java.lang.String parameterTypeNames)  
    • Field Detail

      • classLoader

        private final java.lang.ClassLoader classLoader
      • className

        private final java.lang.String className
      • methodName

        private final java.lang.String methodName
      • parameterTypeNames

        private final java.lang.String parameterTypeNames
      • javaClass

        private volatile java.lang.Class<?> javaClass
      • javaMethod

        private volatile java.lang.reflect.Method javaMethod
      • parameterTypes

        private volatile java.lang.Class<?>[] parameterTypes
    • Constructor Detail

      • MethodSelector

        MethodSelector​(java.lang.ClassLoader classLoader,
                       java.lang.String className,
                       java.lang.String methodName,
                       java.lang.String parameterTypeNames)
        Since:
        1.10
      • MethodSelector

        MethodSelector​(java.lang.Class<?> javaClass,
                       java.lang.String methodName,
                       java.lang.String parameterTypeNames)
      • MethodSelector

        MethodSelector​(java.lang.ClassLoader classLoader,
                       java.lang.String className,
                       java.lang.String methodName,
                       java.lang.Class<?>... parameterTypes)
        Since:
        1.10
      • MethodSelector

        MethodSelector​(java.lang.Class<?> javaClass,
                       java.lang.String methodName,
                       java.lang.Class<?>... parameterTypes)
        Since:
        1.10
      • MethodSelector

        MethodSelector​(java.lang.Class<?> javaClass,
                       java.lang.reflect.Method method)
    • Method Detail

      • getClassLoader

        @API(status=EXPERIMENTAL,
             since="1.10")
        public java.lang.ClassLoader getClassLoader()
        Get the ClassLoader used to load the specified class.
        Returns:
        the ClassLoader; potentially null
        Since:
        1.10
      • getClassName

        public java.lang.String getClassName()
        Get the selected class name.
      • getMethodName

        public java.lang.String getMethodName()
        Get the selected method name.
      • getParameterTypeNames

        @API(status=STABLE,
             since="1.10")
        public java.lang.String getParameterTypeNames()
        Get the names of parameter types for the selected method as a String, typically a comma-separated list of primitive types, fully qualified class names, or array types.

        Note: the names of parameter types are provided as a single string instead of a collection in order to allow this selector to be used in a generic fashion by various test engines. It is therefore the responsibility of the caller of this method to determine how to parse the returned string.

        Returns:
        the names of parameter types supplied to this MethodSelector via a constructor or deduced from a Method or parameter types supplied via a constructor; never null but potentially an empty string
        Since:
        1.10
        See Also:
        getParameterTypes()
      • getJavaClass

        public java.lang.Class<?> getJavaClass()
        Get the Class in which the selected method is declared, or a subclass thereof.

        If the Class was not provided, but only the name, this method attempts to lazily load the Class based on its name and throws a PreconditionViolationException if the class cannot be loaded.

        See Also:
        getJavaMethod()
      • getJavaMethod

        public java.lang.reflect.Method getJavaMethod()
        Get the selected Method.

        If the Method was not provided, but only the name, this method attempts to lazily load the Method based on its name and throws a PreconditionViolationException if the method cannot be loaded.

        See Also:
        getJavaClass()
      • getParameterTypes

        @API(status=EXPERIMENTAL,
             since="1.10")
        public java.lang.Class<?>[] getParameterTypes()
        Get the parameter types for the selected method.

        If the parameter types were not provided as Class references (or could not be deduced as Class references in the constructor), this method attempts to lazily load the class reference for each parameter type based on its name and throws a JUnitException if the class cannot be loaded.

        Returns:
        the method's parameter types; never null but potentially an empty array if the selected method does not declare parameters
        Since:
        1.10
        See Also:
        getParameterTypeNames(), Method.getParameterTypes()
      • lazyLoadJavaClass

        private void lazyLoadJavaClass()
      • lazyLoadJavaMethod

        private void lazyLoadJavaMethod()
      • lazyLoadParameterTypes

        private void lazyLoadParameterTypes()
      • equals

        @API(status=STABLE,
             since="1.3")
        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
        Since:
        1.3
      • hashCode

        @API(status=STABLE,
             since="1.3")
        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        Since:
        1.3
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object