Enum Class Part.Type

java.lang.Object
java.lang.Enum<Part.Type>
com.perfino.annotation.Part.Type
All Implemented Interfaces:
Serializable, Comparable<Part.Type>, Constable
Enclosing class:
Part

public static enum Part.Type extends Enum<Part.Type>
The kind of information that is added by a Part. The type determines which parameters of the @Part annotation are applicable.
  • Enum Constant Details

    • TEXT

      public static final Part.Type TEXT
      Fixed text. For this type, the Part.text() parameter is used to set the text. TEXT is the default for Part.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

      public static final Part.Type CLASS
      The value of this part depends on the Inheritance.Mode: For this type, the 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, set packageMode to PackageMode.ABBREVIATED or PackageMode.FULL:
         @Part(value = Type.CLASS, packageMode = PackageMode.FULL)
    • METHOD

      public static final Part.Type 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

      public static final Part.Type PARAMETER
      The string representation of a method parameter. This part is only available if used in a MethodTransaction 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 is null, 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

      public static final Part.Type INSTANCE
      The string representation of the instance on which the instrumented method is called. This part works for both MethodTransaction and ClassTransaction, 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

      public static final Part.Type INSTANCE_CLASS
      The class name of the instance on which the instrumented method is called. This part works for both MethodTransaction and ClassTransaction. For static methods it yields the same value as CLASS.

      The difference with respect to the CLASS type with Inheritance.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, the INSTANCE_CLASS type supports the parameter Part.packageMode() to control if and how package names should be added.

  • Method Details

    • values

      public static Part.Type[] 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

      public static Part.Type valueOf(String name)
      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 name
      NullPointerException - if the argument is null