Package net.bytebuddy
Class NamingStrategy.SuffixingRandom
- java.lang.Object
-
- net.bytebuddy.NamingStrategy.AbstractBase
-
- net.bytebuddy.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:- The super classes package and name
- A given suffix string
- A random number
$
sign is included into the name to improve readability. As an exception, types that subclass classes from thejava.**
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
NamingStrategy.SuffixingRandom.BaseNameResolver
A base name resolver is responsible for resolving a name onto which the suffix is appended.-
Nested classes/interfaces inherited from interface net.bytebuddy.NamingStrategy
NamingStrategy.AbstractBase, NamingStrategy.PrefixingRandom, NamingStrategy.SuffixingRandom
-
-
Field Summary
Fields Modifier and Type Field Description private NamingStrategy.SuffixingRandom.BaseNameResolver
baseNameResolver
A resolver for the base name for naming the unnamed type.static java.lang.String
BYTE_BUDDY_RENAME_PACKAGE
The default package for defining types that are renamed to not be contained in theJAVA_PACKAGE
package.private static java.lang.String
JAVA_PACKAGE
The package prefix of thejava.*
packages for which the definition of non-bootstrap types is illegal.private java.lang.String
javaLangPackagePrefix
The renaming location for types of theJAVA_PACKAGE
.static java.lang.String
NO_PREFIX
Indicates that types of thejava.*
package should not be prefixed.private RandomString
randomString
An instance for creating random seed values.private java.lang.String
suffix
The suffix to attach to a super type name.
-
Constructor Summary
Constructors Constructor Description SuffixingRandom(java.lang.String suffix)
Creates an immutable naming strategy with a given suffix but moves types that subclass types within thejava.lang
package into Byte Buddy's package namespace.SuffixingRandom(java.lang.String suffix, java.lang.String javaLangPackagePrefix)
Creates an immutable naming strategy with a given suffix but moves types that subclass types within thejava.lang
package into Byte Buddy's package namespace.SuffixingRandom(java.lang.String suffix, NamingStrategy.SuffixingRandom.BaseNameResolver baseNameResolver)
Creates an immutable naming strategy with a given suffix but moves types that subclass types within thejava.lang
package into Byte Buddy's package namespace.SuffixingRandom(java.lang.String suffix, NamingStrategy.SuffixingRandom.BaseNameResolver baseNameResolver, java.lang.String javaLangPackagePrefix)
Creates an immutable naming strategy with a given suffix but moves types that subclass types within thejava.lang
package into a given namespace.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
name(TypeDescription superClass)
Determines a new name when creating a new type that subclasses the provided type.-
Methods inherited from class net.bytebuddy.NamingStrategy.AbstractBase
rebase, redefine, subclass
-
-
-
-
Field Detail
-
BYTE_BUDDY_RENAME_PACKAGE
public static final java.lang.String BYTE_BUDDY_RENAME_PACKAGE
The default package for defining types that are renamed to not be contained in theJAVA_PACKAGE
package.- See Also:
- Constant Field Values
-
NO_PREFIX
public static final java.lang.String NO_PREFIX
Indicates that types of thejava.*
package should not be prefixed.- See Also:
- Constant Field Values
-
JAVA_PACKAGE
private static final java.lang.String JAVA_PACKAGE
The package prefix of thejava.*
packages for which the definition of non-bootstrap types is illegal.- See Also:
- Constant Field Values
-
suffix
private final java.lang.String suffix
The suffix to attach to a super type name.
-
javaLangPackagePrefix
private final java.lang.String javaLangPackagePrefix
The renaming location for types of theJAVA_PACKAGE
.
-
randomString
@ValueHandling(IGNORE) private final RandomString randomString
An instance for creating random seed values.
-
baseNameResolver
private final NamingStrategy.SuffixingRandom.BaseNameResolver baseNameResolver
A resolver for the base name for naming the unnamed type.
-
-
Constructor Detail
-
SuffixingRandom
public SuffixingRandom(java.lang.String suffix)
Creates an immutable naming strategy with a given suffix but moves types that subclass types within thejava.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(java.lang.String suffix, java.lang.String javaLangPackagePrefix)
Creates an immutable naming strategy with a given suffix but moves types that subclass types within thejava.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 thejava.*
namespace. If The prefix is set to the empty string, no prefix is added.
-
SuffixingRandom
public SuffixingRandom(java.lang.String suffix, NamingStrategy.SuffixingRandom.BaseNameResolver baseNameResolver)
Creates an immutable naming strategy with a given suffix but moves types that subclass types within thejava.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(java.lang.String suffix, NamingStrategy.SuffixingRandom.BaseNameResolver baseNameResolver, java.lang.String javaLangPackagePrefix)
Creates an immutable naming strategy with a given suffix but moves types that subclass types within thejava.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 thejava.*
namespace. If The prefix is set to the empty string, no prefix is added.
-
-
Method Detail
-
name
protected java.lang.String name(TypeDescription superClass)
Description copied from class:NamingStrategy.AbstractBase
Determines a new name when creating a new type that subclasses the provided type.- Specified by:
name
in classNamingStrategy.AbstractBase
- Parameters:
superClass
- The super type of the created type.- Returns:
- The name of the dynamic type.
-
-