Enum Part.Type

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Part.Type>
    Enclosing class:
    Part

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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Part.Type valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static Part.Type[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • 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.

      • 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 Detail

      • values

        public static Part.Type[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Part.Type c : Part.Type.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Part.Type valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null