Package net.bytebuddy.dynamic
Class ClassFileLocator.Simple
- java.lang.Object
-
- net.bytebuddy.dynamic.ClassFileLocator.Simple
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,ClassFileLocator
- Enclosing interface:
- ClassFileLocator
@Enhance public static class ClassFileLocator.Simple extends java.lang.Object implements ClassFileLocator
A simple class file locator that returns class files from a selection of given types.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.ClassFileLocator
ClassFileLocator.AgentBased, ClassFileLocator.Compound, ClassFileLocator.ForClassLoader, ClassFileLocator.ForFolder, ClassFileLocator.ForJarFile, ClassFileLocator.ForModule, ClassFileLocator.ForModuleFile, ClassFileLocator.ForUrl, ClassFileLocator.NoOp, ClassFileLocator.PackageDiscriminating, ClassFileLocator.Resolution, ClassFileLocator.Simple
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,byte[]>
classFiles
The class files that are known to this class file locator mapped by their type name.-
Fields inherited from interface net.bytebuddy.dynamic.ClassFileLocator
CLASS_FILE_EXTENSION
-
-
Constructor Summary
Constructors Constructor Description Simple(java.util.Map<java.lang.String,byte[]> classFiles)
Creates a new simple class file locator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
ClassFileLocator.Resolution
locate(java.lang.String name)
Locates the class file for a given type and returns the binary data of the class file.static ClassFileLocator
of(java.lang.String typeName, byte[] binaryRepresentation)
Creates a class file locator for a single known type.static ClassFileLocator
of(java.util.Map<TypeDescription,byte[]> binaryRepresentations)
Creates a class file locator that represents all types of a dynamic type.static ClassFileLocator
of(DynamicType dynamicType)
Creates a class file locator that represents all types of a dynamic type.static ClassFileLocator
ofResources(java.util.Map<java.lang.String,byte[]> binaryRepresentations)
Creates a class file locator of a map of resources where class files are mapped by their path and file extension.
-
-
-
Method Detail
-
of
public static ClassFileLocator of(java.lang.String typeName, byte[] binaryRepresentation)
Creates a class file locator for a single known type.- Parameters:
typeName
- The name of the type.binaryRepresentation
- The binary representation of the type.- Returns:
- An appropriate class file locator.
-
of
public static ClassFileLocator of(DynamicType dynamicType)
Creates a class file locator that represents all types of a dynamic type.- Parameters:
dynamicType
- The dynamic type to represent.- Returns:
- A class file locator representing the dynamic type's types.
-
of
public static ClassFileLocator of(java.util.Map<TypeDescription,byte[]> binaryRepresentations)
Creates a class file locator that represents all types of a dynamic type.- Parameters:
binaryRepresentations
- The binary representation of all types.- Returns:
- A class file locator representing the dynamic type's types.
-
ofResources
public static ClassFileLocator ofResources(java.util.Map<java.lang.String,byte[]> binaryRepresentations)
Creates a class file locator of a map of resources where class files are mapped by their path and file extension.- Parameters:
binaryRepresentations
- A map of resource names to their binary representation.- Returns:
- A class file locator that finds class files within the map.
-
locate
public ClassFileLocator.Resolution locate(java.lang.String name)
Locates the class file for a given type and returns the binary data of the class file.- Specified by:
locate
in interfaceClassFileLocator
- Parameters:
name
- The name of the type to locate a class file representation for.- Returns:
- Any binary representation of the type which might be illegal.
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
-