Package net.bytebuddy

Class NamingStrategy.SuffixingRandom

  • All Implemented Interfaces:
    NamingStrategy
    Enclosing interface:
    NamingStrategy

    @Enhance
    public static class NamingStrategy.SuffixingRandom
    extends NamingStrategy.AbstractBase
    A naming strategy that creates a name by concatenating:
    1. The super classes package and name
    2. A given suffix string
    3. A random number
    Between all these elements, a $ sign is included into the name to improve readability. As an exception, types that subclass classes from the java.** packages are prefixed with a given package. This is necessary as it is illegal to define non-bootstrap classes in this name space. The same strategy is applied when subclassing a signed type which is equally illegal.
    • Field Detail

      • BYTE_BUDDY_RENAME_PACKAGE

        public static final String BYTE_BUDDY_RENAME_PACKAGE
        The default package for defining types that are renamed to not be contained in the JAVA_PACKAGE package.
        See Also:
        Constant Field Values
      • NO_PREFIX

        public static final String NO_PREFIX
        Indicates that types of the java.* package should not be prefixed.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SuffixingRandom

        public SuffixingRandom​(String suffix)
        Creates an immutable naming strategy with a given suffix but moves types that subclass types within the java.lang package into Byte Buddy's package namespace. All names are derived from the unnamed type's super type.
        Parameters:
        suffix - The suffix for the generated class.
      • SuffixingRandom

        public SuffixingRandom​(String suffix,
                               String javaLangPackagePrefix)
        Creates an immutable naming strategy with a given suffix but moves types that subclass types within the java.lang package into Byte Buddy's package namespace.
        Parameters:
        suffix - The suffix for the generated class.
        javaLangPackagePrefix - The fallback namespace for type's that subclass types within the java.* namespace. If The prefix is set to the empty string, no prefix is added.
      • SuffixingRandom

        public SuffixingRandom​(String suffix,
                               NamingStrategy.SuffixingRandom.BaseNameResolver baseNameResolver)
        Creates an immutable naming strategy with a given suffix but moves types that subclass types within the java.lang package into Byte Buddy's package namespace.
        Parameters:
        suffix - The suffix for the generated class.
        baseNameResolver - The base name resolver that is queried for locating the base name.
      • SuffixingRandom

        public SuffixingRandom​(String suffix,
                               NamingStrategy.SuffixingRandom.BaseNameResolver baseNameResolver,
                               String javaLangPackagePrefix)
        Creates an immutable naming strategy with a given suffix but moves types that subclass types within the java.lang package into a given namespace.
        Parameters:
        suffix - The suffix for the generated class.
        baseNameResolver - The base name resolver that is queried for locating the base name.
        javaLangPackagePrefix - The fallback namespace for type's that subclass types within the java.* namespace. If The prefix is set to the empty string, no prefix is added.