Class TypeCasting
- java.lang.Object
-
- net.bytebuddy.implementation.bytecode.assign.TypeCasting
-
- All Implemented Interfaces:
StackManipulation
@Enhance public class TypeCasting extends java.lang.Object implements StackManipulation
A stack manipulation for a type down casting. Such castings are not implicit but must be performed explicitly.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.bytecode.StackManipulation
StackManipulation.Compound, StackManipulation.Illegal, StackManipulation.Size, StackManipulation.Trivial
-
-
Field Summary
Fields Modifier and Type Field Description private TypeDescription
typeDescription
The type description to which a value should be casted.
-
Constructor Summary
Constructors Modifier Constructor Description protected
TypeCasting(TypeDescription typeDescription)
Creates a new type casting.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StackManipulation.Size
apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext)
Applies the stack manipulation that is described by this instance.boolean
isValid()
Determines if this stack manipulation is valid.static StackManipulation
to(TypeDefinition typeDefinition)
Creates a casting to the given, non-primitive type.
-
-
-
Field Detail
-
typeDescription
private final TypeDescription typeDescription
The type description to which a value should be casted.
-
-
Constructor Detail
-
TypeCasting
protected TypeCasting(TypeDescription typeDescription)
Creates a new type casting.- Parameters:
typeDescription
- The type description to which a value should be casted.
-
-
Method Detail
-
to
public static StackManipulation to(TypeDefinition typeDefinition)
Creates a casting to the given, non-primitive type.- Parameters:
typeDefinition
- The type to which a value should be casted.- Returns:
- A stack manipulation that represents the casting.
-
isValid
public boolean isValid()
Determines if this stack manipulation is valid.- Specified by:
isValid
in interfaceStackManipulation
- Returns:
- If
false
, this manipulation cannot be applied and should throw an exception.
-
apply
public StackManipulation.Size apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext)
Applies the stack manipulation that is described by this instance.- Specified by:
apply
in interfaceStackManipulation
- Parameters:
methodVisitor
- The method visitor used to write the method implementation to.implementationContext
- The context of the current implementation.- Returns:
- The changes to the size of the operand stack that are implied by this stack manipulation.
-
-