Module nl.jqno.equalsverifier
Class ClassProbe<T>
java.lang.Object
nl.jqno.equalsverifier.internal.reflection.ClassProbe<T>
Provides read-only reflective access to a class.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines whether T has anequalsmethod.booleanDetermines whether T has ahashCodemethod.private static booleandeclaresMethod(Class<?> type, String name, Class<?>... parameterTypes) findConstructor(Class<?>[] params) Finds a constructor (no matter its accessibility) in T or its superclasses.Finds a field (no matter its accessibility) in T or its superclasses.findMethod(String name, Class<?>... parameterTypes) private static <T> Constructor<T> getConstructor(Class<T> type, Class<?>[] params) private static Fieldprivate static MethodClassProbe<? super T> Returns a probe for T's superclass.getType()Returns the class on whichClassProbeoperates.booleanDetermines whether T has a method with the given name and parameters.booleanDetermines whether T is abstract.booleanReturns whether T is a single-value enum.booleanDetermines whether T'sequalsmethod is abstract.booleanDetermines whether T'sequalsmethod is inherited fromObject.booleanDetermines whether T'shashCodemethod is abstract.private booleanisMethodAbstract(String name, Class<?>... parameterTypes) booleanisMethodFinal(String methodName, Class<?>... parameterTypes) Determines whether the given method in T is final.booleanisRecord()Determines whether T is a Java Record.booleanisSealed()Determines whether T is a sealed class.static <T> ClassProbe<T> Factory method.
-
Field Details
-
type
-
-
Constructor Details
-
ClassProbe
Private constructor. Callof(Class)instead.
-
-
Method Details
-
of
Factory method.- Type Parameters:
T- The class on whichClassProbeoperates.- Parameters:
type- The class on whichClassProbeoperates.- Returns:
- A
ClassProbefor T.
-
getType
Returns the class on whichClassProbeoperates.- Returns:
- The class on which
ClassProbeoperates.
-
isRecord
public boolean isRecord()Determines whether T is a Java Record.- Returns:
- true if T is a Java Record.
-
isSealed
public boolean isSealed()Determines whether T is a sealed class.- Returns:
- true if T is a sealed class
-
isAbstract
public boolean isAbstract()Determines whether T is abstract.- Returns:
- true if T is abstract.
-
isEmptyOrSingleValueEnum
public boolean isEmptyOrSingleValueEnum()Returns whether T is a single-value enum.- Returns:
- Whether T is an enum with a single value.
-
declaresEquals
public boolean declaresEquals()Determines whether T has anequalsmethod.- Returns:
- True if T has an
equalsmethod.
-
declaresHashCode
public boolean declaresHashCode()Determines whether T has ahashCodemethod.- Returns:
- True if T has a
hashCodemethod.
-
hasMethod
Determines whether T has a method with the given name and parameters.- Parameters:
name- The name of the method we're looking for.- Returns:
- True if T has a method with the given name and parameters.
-
declaresMethod
-
isEqualsAbstract
public boolean isEqualsAbstract()Determines whether T'sequalsmethod is abstract.- Returns:
- True if T's
equalsmethod is abstract.
-
isHashCodeAbstract
public boolean isHashCodeAbstract()Determines whether T'shashCodemethod is abstract.- Returns:
- True if T's
hashCodemethod is abstract.
-
isMethodAbstract
-
isEqualsInheritedFromObject
public boolean isEqualsInheritedFromObject()Determines whether T'sequalsmethod is inherited fromObject. -
findField
Finds a field (no matter its accessibility) in T or its superclasses.- Parameters:
name- The name of the field that should be found.- Returns:
- The field wrapped in an Optional, or an empty Optional if the field could not be found.
-
getField
-
isMethodFinal
Determines whether the given method in T is final.- Parameters:
methodName- The name of the method in T.parameterTypes- The types of the method's parameters, to determine the right overload.- Returns:
- True if the given method in T is final, false if it's not final or if it doesn't exist.
-
findMethod
-
getMethod
-
findConstructor
Finds a constructor (no matter its accessibility) in T or its superclasses.- Parameters:
params- The types of the parameters of the constructor that should be found.- Returns:
- The field wrapped in an Optional, or an empty Optional if the field could not be found.
-
getConstructor
-
getSuperProbe
Returns a probe for T's superclass.- Returns:
- A probe for T's superclass.
-