Class KiwiReflection2

java.lang.Object
org.kiwiproject.beta.reflect.KiwiReflection2

@Beta public final class KiwiReflection2 extends Object
Utilities related to reflection.

These utilities can be considered for inclusion into kiwi's KiwiReflection class.

  • Method Details

    • hasAccessModifier

      public static boolean hasAccessModifier(Member member, KiwiReflection2.JavaAccessModifier modifier)
      Check whether a Member has a given access modifier.
      Parameters:
      member - the Java member to check
      modifier - the modified to check against
      Returns:
      true if the member has the given modifier, otherwise false
    • hasAccessModifier

      public static boolean hasAccessModifier(Class<?> clazz, KiwiReflection2.JavaAccessModifier modifier)
      Check whether a Class has a given access modifier.
      Parameters:
      clazz - the Java class to check
      modifier - the modified to check against
      Returns:
      true if the class has the given modifier, otherwise false
    • isPublic

      public static boolean isPublic(Member member)
      Check if the member has the public modifier.
      Parameters:
      member - the member to check
      Returns:
      true if the member is public, otherwise false
    • isPublic

      public static boolean isPublic(Class<?> clazz)
      Check if the class has the public modifier.
      Parameters:
      clazz - the class to check
      Returns:
      true if the class is public, otherwise false
    • isProtected

      public static boolean isProtected(Member member)
      Check if the member has the protected modifier.
      Parameters:
      member - the member to check
      Returns:
      true if the member is protected, otherwise false
    • isProtected

      public static boolean isProtected(Class<?> clazz)
      Check if the class has the protected modifier.
      Parameters:
      clazz - the class to check
      Returns:
      true if the class is protected, otherwise false
    • isPrivate

      public static boolean isPrivate(Member member)
      Check if the member has the private modifier.
      Parameters:
      member - the member to check
      Returns:
      true if the member is private, otherwise false
    • isPrivate

      public static boolean isPrivate(Class<?> clazz)
      Check if the class has the private modifier.
      Parameters:
      clazz - the class to check
      Returns:
      true if the class is private, otherwise false
    • isPackagePrivate

      public static boolean isPackagePrivate(Member member)
      Check if the member has no explicit modifier, i.e., is accessible only by other members of the same package.
      Parameters:
      member - the member to check
      Returns:
      true, if the member has no explicit modifier, otherwise false
    • isPackagePrivate

      public static boolean isPackagePrivate(Class<?> clazz)
      Check if the class has no explicit modifier, i.e., is accessible only by other classes and members in the same package.
      Parameters:
      clazz - the class to check
      Returns:
      true if the class has no explicit modifier, otherwise false
    • typeInformationOf

      public static TypeInfo typeInformationOf(@NonNull Field field)
      Get the type information for the given Field.
      Parameters:
      field - the Field to check
      Returns:
      the type information
    • typeInformationOf

      public static TypeInfo typeInformationOf(@NonNull Type type)
      Get the type information for the given Type.

      This is a convenience method that delegates to TypeInfo.ofType(Type).

      Parameters:
      type - the type to check
      Returns:
      the type information