Module nl.jqno.equalsverifier
Class SubtypeManager
java.lang.Object
nl.jqno.equalsverifier.internal.reflection.SubtypeManager
Can find subtypes that can be instantiated. Useful for abstract classes, interfaces, and sealed types.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> Class<T> findInstantiablePermittedSubclass(ClassProbe<T> probe, ValueProvider vp, Attributes attributes) static <T> Class<T> findInstantiableSubclass(ClassProbe<T> probe, ValueProvider vp, Attributes attributes) Finds a subtype that can be instantiated.private static <S> net.bytebuddy.dynamic.loading.ClassLoadingStrategy<ClassLoader> getClassLoadingStrategy(Class<S> context) private static StringgetPackageName(Class<?> type) static <S> Class<S> giveDynamicSubclass(Class<S> superclass) Generates an anonymous subclass of S.static <S> Class<S> giveDynamicSubclass(Class<S> superclass, String nameSuffix, UnaryOperator<net.bytebuddy.dynamic.DynamicType.Builder<S>> modify) Generates an anonymous subclass of S.private static <T> booleanisRecursive(Class<T> type, ValueProvider vp, Attributes attributes) private static booleanisSystemClass(String className) private static <T> booleanisUsable(Class<T> type, ValueProvider vp, Attributes attributes)
-
Field Details
-
FORBIDDEN_PACKAGES
-
FALLBACK_PACKAGE_NAME
-
-
Constructor Details
-
SubtypeManager
private SubtypeManager()
-
-
Method Details
-
findInstantiableSubclass
public static <T> Class<T> findInstantiableSubclass(ClassProbe<T> probe, ValueProvider vp, Attributes attributes) Finds a subtype that can be instantiated.- Type Parameters:
T- Represent the class to find an instantiable subtype for.- Parameters:
probe- Represents the class to find an instantiable subtype for.vp- Used to test if the subtype of a sealed type can indeed be instantiated.attributes- Used by thevp.- Returns:
- An instantiable subtype, or
nullif none can be found. - Throws:
NoValueException- if no subtype can be found. This only happens for sealed types, when all permitted subclasses are recursive.
-
giveDynamicSubclass
Generates an anonymous subclass of S. The subclass is generated dynamically.- Type Parameters:
S- The class to create a dynamic subclass of.- Parameters:
superclass- The class to create a dynamic subclass of.- Returns:
- An instance of an anonymous subclass of S.
-
giveDynamicSubclass
public static <S> Class<S> giveDynamicSubclass(Class<S> superclass, String nameSuffix, UnaryOperator<net.bytebuddy.dynamic.DynamicType.Builder<S>> modify) Generates an anonymous subclass of S. The subclass is generated dynamically.- Type Parameters:
S- The class to create a dynamic subclass of.- Parameters:
superclass- The class to create a dynamic subclass of.nameSuffix- A constant that will be appended to the name of the newly generated class.modify- Allows custom modifications to the generated class.- Returns:
- An instance of an anonymous subclass of S.
-
findInstantiablePermittedSubclass
private static <T> Class<T> findInstantiablePermittedSubclass(ClassProbe<T> probe, ValueProvider vp, Attributes attributes) -
isUsable
-
isRecursive
-
findAllInstantiablePermittedSubclasses
-
getClassLoadingStrategy
private static <S> net.bytebuddy.dynamic.loading.ClassLoadingStrategy<ClassLoader> getClassLoadingStrategy(Class<S> context) -
isSystemClass
-
getPackageName
-