Enum Class Part.Type
- All Implemented Interfaces:
Serializable
,Comparable<Part.Type>
,Constable
- Enclosing class:
Part
Part
.
The type determines which parameters of the @Part
annotation are applicable.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe value of this part depends on theInheritance.Mode
: ForInheritance.Mode.NONE
orInheritance.Mode.WITH_SUPERCLASS_NAME
, it is the name of the class where this annotation is placed.The string representation of the instance on which the instrumented method is called.The class name of the instance on which the instrumented method is called.The name of the annotated method.The string representation of a method parameter.Fixed text. -
Method Summary
-
Enum Constant Details
-
TEXT
Fixed text. For this type, thePart.text()
parameter is used to set the text.TEXT
is the default forPart.value()
, so you can write@Part(text = "Some text")
If you concatenate a
TEXT
part with other parts, you might have to add surrounding space to the text. -
CLASS
The value of this part depends on theInheritance.Mode
:-
For
Inheritance.Mode.NONE
orInheritance.Mode.WITH_SUPERCLASS_NAME
, it is the name of the class where this annotation is placed. For aClassTransaction
, this is the annotated class, for aMethodTransaction
, this is the class surrounding the annotated method. -
For
Inheritance.Mode.WITH_SUBCLASS_NAMES
, it is the name of the class where the instrumented method is defined. If a method is overridden in a subclass, the name of the subclass is used.
Part.packageMode()
parameter is used to control the format of the class name. By default, only the simple class name is added. In that case, you can omit the "value" parameter name:@Part(Type.CLASS)
If you need the package name to be added, setpackageMode
toPackageMode.ABBREVIATED
orPackageMode.FULL
:@Part(value = Type.CLASS, packageMode = PackageMode.FULL)
-
For
-
METHOD
The name of the annotated method.The method name is added without the signature and without the class name.
Since there are no further applicable parameters for this type, it can always be specified without the "value" parameter name:
@Part(Type.METHOD)
-
PARAMETER
The string representation of a method parameter. This part is only available if used in aMethodTransaction
and will produce an empty string otherwise.For this type, the
Part.parameterIndex()
parameter is used to select the desired parameter. By default, the first parameter is used (index 0), so you can write@Part(Type.PARAMETER)
in that case. If another parameter should be used, the "value" parameter name has to be specified for the type:
@Part(value = Type.PARAMETER, parameterIndex = 2)
The parameter index is zero-based, so this will select the third parameter.
The
toString()
method will be called on the selected parameter. If the value is primitive, the primitive string representation is added. If the value isnull
, the string "null" will be added. You can optionally apply a getter chain to the selected parameter and add the result of the getter chain instead of the parameter. For example:@Part(value = Type.PARAMETER, parameterIndex = 1, getterChain = "getUser().getName()")
See the documentation for
Part.getterChain()
for more information. -
INSTANCE
The string representation of the instance on which the instrumented method is called. This part works for bothMethodTransaction
andClassTransaction
, but not for static methods. In that case, the value of the part will be empty.The
toString()
method will be called on the instance. You can optionally apply a getter chain to the instance and add the result of the getter chain instead of the parameter. For example:@Part(value = Type.INSTANCE, getterChain = "getUser().getName()")
See the documentation for
Part.getterChain()
for more information. -
INSTANCE_CLASS
The class name of the instance on which the instrumented method is called. This part works for bothMethodTransaction
andClassTransaction
. For static methods it yields the same value asCLASS
.The difference with respect to the
CLASS
type withInheritance.Mode.WITH_SUBCLASS_NAMES
is that for a subclass, the class name of the actual class is added and not the class name where the instrumented method has been defined. For example, if the instrumented method follows the template method pattern, you can capture the actual class name to distinguish between different sub step implementations.The
CLASS
type imposes less overhead, so it is preferable if you don't need to know the actual class name.Just like the
CLASS
type, theINSTANCE_CLASS
type supports the parameterPart.packageMode()
to control if and how package names should be added.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-