@Retention(value=RUNTIME) @Target(value=TYPE) public @interface TargetClass
value() or className() specify the original class either as a class literal or by
name. Optionally, inner classes can be specified using the innerClass() property.
Distinguished using additional annotations, the original class is modified in different ways:
Delete or Substitute: the annotated class is an alias for the
original class. This is the most frequently used case. All methods and fields of the annotated
class must be annotated too:
Alias: The annotated method or field is an alias for the original element, i.e., the
annotated element does not exist at run time. All usages of the annotated element reference the
original element. For fields, the original field can be further modified using the
RecomputeFieldValue and InjectAccessors annotations (see the documentation of the
annotations for details).Delete: The annotated method or field, as well as the original element, do not exist.
Any usage of them will be reported as an error.Substitute: The annotated method replaces the original method.AnnotateOriginal: The original method remains mostly unchanged, but with one
exception: all annotations on the annotated method are also present on the original method.Delete: The annotated class, as well as the original class, do not exist. Any usage
of them will be reported as an error.Substitute: The annotated class replaces the original class. All fields and methods
of the original class are per default treated as deleted, i.e., any usage of them will be
reported as an error, with the following exception: A method annotated with Substitute
replaces the original method, i.e., calls to the original method now call the annotated method; a
method annotated with KeepOriginal keeps the original method, i.e., calls to the original
method still call the original method.| Modifier and Type | Fields and Description |
|---|---|
static Class<? extends BooleanSupplier> |
DEFAULT_TARGETCLASS_PREDICATE |
| Modifier and Type | Optional Element and Description |
|---|---|
String |
className
Specifies the substitutee class.
|
Class<? extends Function<TargetClass,String>> |
classNameProvider
Specifies the substitutee class.
|
String |
innerClass
Specifies the suffix of the substitutee class name when it is an inner class.
|
Class<? extends BooleanSupplier>[] |
onlyWith
Substitute only if predicates are true (default: unconditional substitutions).
|
Class<?> |
value
Specifies the substitutee class.
|
public static final Class<? extends BooleanSupplier> DEFAULT_TARGETCLASS_PREDICATE
public abstract Class<?> value
className() or classNameProvider() element.public abstract String className
value() or classNameProvider() element.public abstract Class<? extends Function<TargetClass,String>> classNameProvider
Function.apply(T) method of the provided class can compute the class name based on
system properties (like the JDK version). This annotation is the argument of the function, so
the function can, e.g., build a class name that incorporates the className()
property.
If the default value is specified for this element, then a non-default value must be given
for the value() or className() element.public abstract String innerClass
public abstract Class<? extends BooleanSupplier>[] onlyWith
Copyright © 2018. All rights reserved.