Class PrimitiveTypeAwareAssigner
java.lang.Object
net.bytebuddy.implementation.bytecode.assign.primitive.PrimitiveTypeAwareAssigner
- All Implemented Interfaces:
Assigner
This assigner is able to handle non-
void
, primitive types. This means:
- If a primitive type is assigned to a non-primitive type, it will attempt to widen the source type into the target type.
- If a primitive type is assigned to a non-primitive type, it will attempt to box the source type and then query the chained assigner for assigning the boxed type to the target type.
- If a non-primitive type is assigned to a primitive type, it will unbox the source type and then attempt a widening of the unboxed type into the target type. If the source type does not represent a wrapper type, it will attempt to infer the boxing type from the target type and check if the source type is assignable to this wrapper type.
- If two non-primitive types are subject of the assignment, it will delegate the assignment to its chained assigner.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.bytecode.assign.Assigner
Assigner.EqualTypesOnly, Assigner.Refusing, Assigner.Typing
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Assigner
Another assigner that is aware of assigning reference types.Fields inherited from interface net.bytebuddy.implementation.bytecode.assign.Assigner
DEFAULT, GENERICS_AWARE
-
Constructor Summary
ConstructorsConstructorDescriptionPrimitiveTypeAwareAssigner
(Assigner referenceTypeAwareAssigner) Creates a new assigner with the given delegate. -
Method Summary
Modifier and TypeMethodDescriptionassign
(TypeDescription.Generic source, TypeDescription.Generic target, Assigner.Typing typing)
-
Field Details
-
referenceTypeAwareAssigner
Another assigner that is aware of assigning reference types. This assigner is queried for assigning non-primitive types or for assigning a boxed type to another non-primitive type.
-
-
Constructor Details
-
PrimitiveTypeAwareAssigner
Creates a new assigner with the given delegate.- Parameters:
referenceTypeAwareAssigner
- A chained assigner that is queried for assignments not involving primitive types.
-
-
Method Details
-
assign
public StackManipulation assign(TypeDescription.Generic source, TypeDescription.Generic target, Assigner.Typing typing) - Specified by:
assign
in interfaceAssigner
- Parameters:
source
- The original type that is to be transformed into thetargetType
.target
- The target type into which thesourceType
is to be converted.typing
- A hint whether the assignment should consider the runtime type of the source type, i.e. if type down or cross castings are allowed. If this hint is set, this is also an indication thatvoid
to non-void
assignments are permitted.- Returns:
- A stack manipulation that transforms the
sourceType
into thetargetType
if this is possible. An illegal stack manipulation otherwise.
-