Package org.kiwiproject.beta.reflect
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
KiwiReflectionclass.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKiwiReflection2.JavaAccessModifierDescribes the access modifiers allowed on Java members, e.g.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.static booleanisPackagePrivate(Member member)Check if the member has no explicit modifier, i.e.static booleanisPrivate(Class<?> clazz)Check if the class has theprivatemodifier.static booleanisPrivate(Member member)Check 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 booleanisPublic(Class<?> clazz)Check if the class has thepublicmodifier.static booleanisPublic(Member member)Check 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 Detail
-
hasAccessModifier
public static boolean hasAccessModifier(Member member, KiwiReflection2.JavaAccessModifier modifier)
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
public static boolean isPublic(Member member)
Check if the member has thepublicmodifier.- 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 thepublicmodifier.- 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 theprotectedmodifier.- 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 theprotectedmodifier.- 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 theprivatemodifier.- 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 theprivatemodifier.- 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 givenField.- Parameters:
field- the Field to check- Returns:
- the type information
-
typeInformationOf
public static TypeInfo typeInformationOf(@NonNull Type type)
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
-
-