Class ToStringMethod

    • Field Detail

      • start

        private final java.lang.String start
        A token that is added between the prefix and the first field value.
      • end

        private final java.lang.String end
        A token that is added after the last field value.
      • separator

        private final java.lang.String separator
        A token that is added between two field values.
      • definer

        private final java.lang.String definer
        A token that is added between a field's name and its value.
    • Constructor Detail

      • ToStringMethod

        protected ToStringMethod​(ToStringMethod.PrefixResolver prefixResolver)
        Creates a new toString implementation.
        Parameters:
        prefixResolver - A resolver for the prefix of a String representation.
      • ToStringMethod

        private ToStringMethod​(ToStringMethod.PrefixResolver prefixResolver,
                               java.lang.String start,
                               java.lang.String end,
                               java.lang.String separator,
                               java.lang.String definer,
                               ElementMatcher.Junction<? super FieldDescription.InDefinedShape> ignored)
        Creates a new toString implementation.
        Parameters:
        prefixResolver - A resolver for the prefix of a String representation.
        start - A token that is added between the prefix and the first field value.
        end - A token that is added after the last field value.
        separator - A token that is added between two field values.
        definer - A token that is added between a field's name and its value.
        ignored - A filter that determines what fields to ignore.
    • Method Detail

      • prefixedByFullyQualifiedClassName

        public static ToStringMethod prefixedByFullyQualifiedClassName()
        Creates a Object.toString() implementation that is prefixed by the fully qualified class name of the instrumented type.
        Returns:
        A Object.toString() implementation that is prefixed by the fully qualified class name of the instrumented type.
      • prefixedByCanonicalClassName

        public static ToStringMethod prefixedByCanonicalClassName()
        Creates a Object.toString() implementation that is prefixed by the canonical class name of the instrumented type.
        Returns:
        A Object.toString() implementation that is prefixed by the canonical class name of the instrumented type.
      • prefixedBySimpleClassName

        public static ToStringMethod prefixedBySimpleClassName()
        Creates a Object.toString() implementation that is prefixed by the simple class name of the instrumented type.
        Returns:
        A Object.toString() implementation that is prefixed by the simple class name of the instrumented type.
      • prefixedBy

        public static ToStringMethod prefixedBy​(java.lang.String prefix)
        Creates a Object.toString() implementation that is prefixed by the supplied string.
        Parameters:
        prefix - The prefix to use.
        Returns:
        A Object.toString() implementation that is prefixed by the supplied string.
      • prefixedBy

        public static ToStringMethod prefixedBy​(ToStringMethod.PrefixResolver prefixResolver)
        Creates a Object.toString() implementation that is prefixed by the string that is supplied by the given prefix resolver.
        Parameters:
        prefixResolver - The prefix resolver to use.
        Returns:
        A Object.toString() implementation that is prefixed by the string that is supplied by the given prefix resolver.
      • withIgnoredFields

        public ToStringMethod withIgnoredFields​(ElementMatcher<? super FieldDescription.InDefinedShape> ignored)
        Returns a new version of this toString method implementation that ignores the specified fields additionally to any previously specified fields.
        Parameters:
        ignored - A matcher to specify any fields that should be ignored.
        Returns:
        A new version of this toString method implementation that also ignores any fields matched by the provided matcher.
      • withTokens

        public Implementation withTokens​(java.lang.String start,
                                         java.lang.String end,
                                         java.lang.String separator,
                                         java.lang.String definer)
        Changes the tokens used for the Object.toString() implementation.
        Parameters:
        start - A token that is added between the prefix and the first field value.
        end - A token that is added after the last field value.
        separator - A token that is added between two field values.
        definer - A token that is added between two field values.
        Returns:
        A new instance of this implementation that uses the supplied tokens.