Top Description Fields Constructors Methods
net.bytebuddy.implementation.bytecode.assign.primitive

public Class PrimitiveTypeAwareAssigner

extends Object
implements Assigner
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.bytecode.assign.Assigner
Annotations
@Enhance
Imports
net.bytebuddy.build.HashCodeAndEqualsPlugin, net.bytebuddy.description.type.TypeDescription, net.bytebuddy.implementation.bytecode.StackManipulation, net.bytebuddy.implementation.bytecode.assign.Assigner

This assigner is able to handle non-void, primitive types. This means:
  1. If a primitive type is assigned to a non-primitive type, it will attempt to widen the source type into the target type.
  2. 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.
  3. 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.
  4. If two non-primitive types are subject of the assignment, it will delegate the assignment to its chained assigner.

Field Summary

Modifier and TypeField and Description
private final Assigner
referenceTypeAwareAssigner

Another assigner that is aware of assigning reference types.

Constructor Summary

AccessConstructor and Description
public
PrimitiveTypeAwareAssigner(Assigner
A chained assigner that is queried for assignments not involving primitive types.
referenceTypeAwareAssigner
)

Creates a new assigner with the given delegate.

Method Summary

Modifier and TypeMethod and Description
public StackManipulation
assign(TypeDescription.Generic
The original type that is to be transformed into the targetType.
source
,
TypeDescription.Generic
The target type into which the sourceType is to be converted.
target
,
Assigner.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 that void to non-void assignments are permitted.
typing
)

Implements net.bytebuddy.implementation.bytecode.assign.Assigner.assign.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

referenceTypeAwareAssignerback to summary
private final Assigner 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 Detail

PrimitiveTypeAwareAssignerback to summary
public PrimitiveTypeAwareAssigner(Assigner referenceTypeAwareAssigner)

Creates a new assigner with the given delegate.

Parameters
referenceTypeAwareAssigner:Assigner

A chained assigner that is queried for assignments not involving primitive types.

Method Detail

assignback to summary
public StackManipulation assign(TypeDescription.Generic source, TypeDescription.Generic target, Assigner.Typing typing)

Implements net.bytebuddy.implementation.bytecode.assign.Assigner.assign.

Parameters
source:TypeDescription.Generic

Doc from net.bytebuddy.implementation.bytecode.assign.Assigner.assign.

The original type that is to be transformed into the targetType.

target:TypeDescription.Generic

Doc from net.bytebuddy.implementation.bytecode.assign.Assigner.assign.

The target type into which the sourceType is to be converted.

typing:Assigner.Typing

Doc from net.bytebuddy.implementation.bytecode.assign.Assigner.assign.

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 that void to non-void assignments are permitted.

Returns:StackManipulation

Doc from net.bytebuddy.implementation.bytecode.assign.Assigner.assign.

A stack manipulation that transforms the sourceType into the targetType if this is possible. An illegal stack manipulation otherwise.