Package org.kiwiproject.beta.reflect
Class KiwiReflection2
java.lang.Object
org.kiwiproject.beta.reflect.KiwiReflection2
Utilities related to reflection.
These utilities can be considered for inclusion into kiwi's KiwiReflection class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDescribes the access modifiers allowed on Java members, e.g., classes, fields, methods, and constructors. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasAccessModifier(Class<?> clazz, KiwiReflection2.JavaAccessModifier modifier) Check whether aClasshas a given access modifier.static booleanhasAccessModifier(Member member, KiwiReflection2.JavaAccessModifier modifier) Check whether aMemberhas a given access modifier.static booleanisPackagePrivate(Class<?> clazz) Check if the class has no explicit modifier, i.e., is accessible only by other classes and members in the same package.static booleanisPackagePrivate(Member member) Check if the member has no explicit modifier, i.e., is accessible only by other members of the same package.static booleanCheck if the class has theprivatemodifier.static booleanCheck if the member has theprivatemodifier.static booleanisProtected(Class<?> clazz) Check if the class has theprotectedmodifier.static booleanisProtected(Member member) Check if the member has theprotectedmodifier.static booleanCheck if the class has thepublicmodifier.static booleanCheck if the member has thepublicmodifier.static TypeInfotypeInformationOf(@NonNull Field field) Get the type information for the givenField.static TypeInfotypeInformationOf(@NonNull Type type) Get the type information for the givenType.
-
Method Details
-
hasAccessModifier
Check whether aMemberhas a given access modifier.- Parameters:
member- the Java member to checkmodifier- 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 aClasshas a given access modifier.- Parameters:
clazz- the Java class to checkmodifier- the modified to check against- Returns:
- true if the class has the given modifier, otherwise false
-
isPublic
Check if the member has thepublicmodifier.- Parameters:
member- the member to check- Returns:
- true if the member is public, otherwise false
-
isPublic
Check if the class has thepublicmodifier.- Parameters:
clazz- the class to check- Returns:
- true if the class is public, otherwise false
-
isProtected
Check if the member has theprotectedmodifier.- Parameters:
member- the member to check- Returns:
- true if the member is protected, otherwise false
-
isProtected
Check if the class has theprotectedmodifier.- Parameters:
clazz- the class to check- Returns:
- true if the class is protected, otherwise false
-
isPrivate
Check if the member has theprivatemodifier.- Parameters:
member- the member to check- Returns:
- true if the member is private, otherwise false
-
isPrivate
Check if the class has theprivatemodifier.- Parameters:
clazz- the class to check- Returns:
- true if the class is private, otherwise false
-
isPackagePrivate
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
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
Get the type information for the givenField.- Parameters:
field- the Field to check- Returns:
- the type information
-
typeInformationOf
Get the type information for the givenType.This is a convenience method that delegates to
TypeInfo.ofType(Type).- Parameters:
type- the type to check- Returns:
- the type information
-