Class ModifierSupport

java.lang.Object
org.junit.platform.commons.support.ModifierSupport

@API(status=MAINTAINED, since="1.4") public final class ModifierSupport extends Object
ModifierSupport provides static utility methods for working with class and member modifiers — for example, to determine if a class or member is declared as public, private, abstract, static, etc.

TestEngine and extension authors are encouraged to use these supported methods in order to align with the behavior of the JUnit Platform.

Since:
1.4
See Also:
Modifier, AnnotationSupport, ClassSupport, ReflectionSupport
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    isAbstract​(Class<?> clazz)
    Determine if the supplied class is abstract.
    static boolean
    isAbstract​(Member member)
    Determine if the supplied member is abstract.
    static boolean
    isFinal​(Class<?> clazz)
    Determine if the supplied class is final.
    static boolean
    isFinal​(Member member)
    Determine if the supplied member is final.
    static boolean
    isNotFinal​(Class<?> clazz)
    Determine if the supplied class is not final.
    static boolean
    isNotFinal​(Member member)
    Determine if the supplied member is not final.
    static boolean
    isNotPrivate​(Class<?> clazz)
    Determine if the supplied class is not private.
    static boolean
    isNotPrivate​(Member member)
    Determine if the supplied member is not private.
    static boolean
    isNotStatic​(Class<?> clazz)
    Determine if the supplied class is not static.
    static boolean
    isNotStatic​(Member member)
    Determine if the supplied member is not static.
    static boolean
    isPrivate​(Class<?> clazz)
    Determine if the supplied class is private.
    static boolean
    isPrivate​(Member member)
    Determine if the supplied member is private.
    static boolean
    isPublic​(Class<?> clazz)
    Determine if the supplied class is public.
    static boolean
    isPublic​(Member member)
    Determine if the supplied member is public.
    static boolean
    isStatic​(Class<?> clazz)
    Determine if the supplied class is static.
    static boolean
    isStatic​(Member member)
    Determine if the supplied member is static.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isPublic

      public static boolean isPublic(Class<?> clazz)
      Determine if the supplied class is public.
      Parameters:
      clazz - the class to check; never null
      Returns:
      true if the class is public
      See Also:
      Modifier.isPublic(int)
    • isPublic

      public static boolean isPublic(Member member)
      Determine if the supplied member is public.
      Parameters:
      member - the member to check; never null
      Returns:
      true if the member is public
      See Also:
      Modifier.isPublic(int)
    • isPrivate

      public static boolean isPrivate(Class<?> clazz)
      Determine if the supplied class is private.
      Parameters:
      clazz - the class to check; never null
      Returns:
      true if the class is private
      See Also:
      Modifier.isPrivate(int)
    • isPrivate

      public static boolean isPrivate(Member member)
      Determine if the supplied member is private.
      Parameters:
      member - the member to check; never null
      Returns:
      true if the member is private
      See Also:
      Modifier.isPrivate(int)
    • isNotPrivate

      public static boolean isNotPrivate(Class<?> clazz)
      Determine if the supplied class is not private.

      In other words this method will return true for classes declared as public, protected, or package private and false for classes declared as private.

      Parameters:
      clazz - the class to check; never null
      Returns:
      true if the class is not private
      See Also:
      Modifier.isPublic(int), Modifier.isProtected(int), Modifier.isPrivate(int)
    • isNotPrivate

      public static boolean isNotPrivate(Member member)
      Determine if the supplied member is not private.

      In other words this method will return true for members declared as public, protected, or package private and false for members declared as private.

      Parameters:
      member - the member to check; never null
      Returns:
      true if the member is not private
      See Also:
      Modifier.isPublic(int), Modifier.isProtected(int), Modifier.isPrivate(int)
    • isAbstract

      public static boolean isAbstract(Class<?> clazz)
      Determine if the supplied class is abstract.
      Parameters:
      clazz - the class to check; never null
      Returns:
      true if the class is abstract
      See Also:
      Modifier.isAbstract(int)
    • isAbstract

      public static boolean isAbstract(Member member)
      Determine if the supplied member is abstract.
      Parameters:
      member - the class to check; never null
      Returns:
      true if the member is abstract
      See Also:
      Modifier.isAbstract(int)
    • isStatic

      public static boolean isStatic(Class<?> clazz)
      Determine if the supplied class is static.
      Parameters:
      clazz - the class to check; never null
      Returns:
      true if the class is static
      See Also:
      Modifier.isStatic(int)
    • isStatic

      public static boolean isStatic(Member member)
      Determine if the supplied member is static.
      Parameters:
      member - the member to check; never null
      Returns:
      true if the member is static
      See Also:
      Modifier.isStatic(int)
    • isNotStatic

      public static boolean isNotStatic(Class<?> clazz)
      Determine if the supplied class is not static.
      Parameters:
      clazz - the class to check; never null
      Returns:
      true if the class is not static
      See Also:
      Modifier.isStatic(int)
    • isNotStatic

      public static boolean isNotStatic(Member member)
      Determine if the supplied member is not static.
      Parameters:
      member - the member to check; never null
      Returns:
      true if the member is not static
      See Also:
      Modifier.isStatic(int)
    • isFinal

      @API(status=MAINTAINED, since="1.5") public static boolean isFinal(Class<?> clazz)
      Determine if the supplied class is final.
      Parameters:
      clazz - the class to check; never null
      Returns:
      true if the class is final
      Since:
      1.5
      See Also:
      Modifier.isFinal(int)
    • isNotFinal

      @API(status=MAINTAINED, since="1.5") public static boolean isNotFinal(Class<?> clazz)
      Determine if the supplied class is not final.
      Parameters:
      clazz - the class to check; never null
      Returns:
      true if the class is not final
      Since:
      1.5
      See Also:
      Modifier.isFinal(int)
    • isFinal

      @API(status=MAINTAINED, since="1.5") public static boolean isFinal(Member member)
      Determine if the supplied member is final.
      Parameters:
      member - the member to check; never null
      Returns:
      true if the member is final
      Since:
      1.5
      See Also:
      Modifier.isFinal(int)
    • isNotFinal

      @API(status=MAINTAINED, since="1.5") public static boolean isNotFinal(Member member)
      Determine if the supplied member is not final.
      Parameters:
      member - the member to check; never null
      Returns:
      true if the member is not final
      Since:
      1.5
      See Also:
      Modifier.isFinal(int)