/** * Returns the wrapper type that this unboxing delegate represents. * * @return A generic version of this delegate's wrapper type. */ protected TypeDescription.Generic getWrapperType() { return wrapperType.asGenericType(); }
/** * Creates a builder for a non-generic type. * * @param typeDescription The type's erasure. * @param ownerType The raw type's raw declaring type or {@code null} if no such type is defined. */ private OfNonGenericType(TypeDescription typeDescription, TypeDescription ownerType) { this(typeDescription, ownerType == null ? Generic.UNDEFINED : ownerType.asGenericType()); }
/** * {@inheritDoc} */ public Generic asRawType() { return asErasure().asGenericType(); }
/** * {@inheritDoc} */ public Generic getComponentType() { TypeDescription componentType = typeDescription.getComponentType(); return componentType == null ? Generic.UNDEFINED : componentType.asGenericType(); }
/** * {@inheritDoc} */ public Generic getOwnerType() { TypeDescription declaringType = typeDescription.getDeclaringType(); return declaringType == null ? Generic.UNDEFINED : declaringType.asGenericType(); }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Context implementationContext, MethodDescription instrumentedMethod) { return apply(methodVisitor, implementationContext, instrumentedMethod, loadedType.asGenericType(), valueLoadInstruction); } }
/** * {@inheritDoc} */ public Generic getComponentType() { TypeDescription componentType = typeDescription.getComponentType(); return componentType == null ? Generic.UNDEFINED : componentType.asGenericType(); }
/** * {@inheritDoc} */ public TypeDescription.Generic getReturnType() { return bridgeType.getReturnType().asGenericType(); }
/** * {@inheritDoc} */ public Generic get(int index) { return rawTypeDescriptors.size() == genericTypeTokens.size() ? TokenizedGenericType.of(typePool, genericTypeTokens.get(index), rawTypeDescriptors.get(index), annotationTokens.get(index), typeVariableSource) : TokenizedGenericType.toErasure(typePool, rawTypeDescriptors.get(index)).asGenericType(); }
/** * Creates a stack manipulation that boxes the represented primitive type and applies a chained assignment * to the result of this boxing operation. * * @param target The type that is target of the assignment operation. * @param chainedAssigner The assigner that is to be used to perform the chained assignment. * @param typing Determines if an assignment to an incompatible type should be enforced by a casting. * @return A stack manipulation that represents the described assignment operation. */ public StackManipulation assignBoxedTo(TypeDescription.Generic target, Assigner chainedAssigner, Assigner.Typing typing) { return new BoxingStackManipulation(chainedAssigner.assign(wrapperType.asGenericType(), target, typing)); }
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(new StackManipulation.Compound(stackManipulation, assigner.assign(primitiveType.asGenericType(), wrapperType.asGenericType(), typing)), wrapperType); }
/** * Creates a new factory for binding an enumeration. * * @param annotationType The annotation type. * @param enumerationDescription The enumeration to bind. */ public Factory(Class<T> annotationType, EnumerationDescription enumerationDescription) { this(annotationType, FieldAccess.forEnumeration(enumerationDescription), enumerationDescription.getEnumerationType().asGenericType()); }
/** * {@inheritDoc} */ public InstrumentedType prepare(InstrumentedType instrumentedType) { return instrumentedType.withField(new FieldDescription.Token(AccessorProxy.FIELD_NAME, Opcodes.ACC_FINAL | Opcodes.ACC_PRIVATE, this.instrumentedType.asGenericType())); }
/** * {@inheritDoc} */ public InstrumentedType prepare(InstrumentedType instrumentedType) { return instrumentedType.withField(new FieldDescription.Token(INSTANCE_FIELD, Opcodes.ACC_PUBLIC | Opcodes.ACC_VOLATILE, implementationTarget.getInstrumentedType().asGenericType())); }
/** * {@inheritDoc} */ protected Resolved doResolve(StackManipulation access, TypeDescription.Generic typeDescription, Assigner assigner, Assigner.Typing typing) { StackManipulation stackManipulation = assigner.assign(typeDescription, this.typeDescription.asGenericType(), typing); if (!stackManipulation.isValid()) { throw new IllegalStateException("Cannot assign " + typeDescription + " to " + this.typeDescription); } return new Resolved.Simple(new StackManipulation.Compound(access, stackManipulation), this.typeDescription); } }
/** * {@inheritDoc} */ public InstrumentedType prepare(InstrumentedType instrumentedType) { return instrumentedType .withField(new FieldDescription.Token(name, Opcodes.ACC_SYNTHETIC | Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC, TypeDescription.ForLoadedType.of(value.getClass()).asGenericType())) .withInitializer(new LoadedTypeInitializer.ForStaticField(name, value)); }
/** * {@inheritDoc} */ protected Resolved doResolve(StackManipulation access, TypeDescription.Generic type, Assigner assigner, Assigner.Typing typing) { StackManipulation stackManipulation = assigner.assign(type, typeDescription.asGenericType(), typing); if (!stackManipulation.isValid()) { throw new IllegalStateException("Cannot assign " + type + " to " + typeDescription); } return new Resolved.Simple(new StackManipulation.Compound(access, stackManipulation), typeDescription); } }
/** * {@inheritDoc} */ public InstrumentedType prepare(InstrumentedType instrumentedType) { return instrumentedType .withField(new FieldDescription.Token(name, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_VOLATILE | Opcodes.ACC_SYNTHETIC, fieldType.asGenericType())) .withInitializer(new LoadedTypeInitializer.ForStaticField(name, value)); } }
@Override protected StackManipulation resolve(MethodDescription interceptedMethod, TypeDescription returnType, Assigner assigner, Assigner.Typing typing) { StackManipulation stackManipulation = assigner.assign(returnType.asGenericType(), interceptedMethod.getReturnType(), typing); if (!stackManipulation.isValid()) { throw new IllegalStateException("Cannot return " + returnType + " from " + interceptedMethod); } return new StackManipulation.Compound(stackManipulation, MethodReturn.of(interceptedMethod.getReturnType())); } },
/** * {@inheritDoc} */ public Boolean onGenericArray(Generic genericArray) { return typeDescription.isArray() ? genericArray.getComponentType().accept(new ForNonGenericType(typeDescription.getComponentType())) : typeDescription.represents(Object.class) || TypeDescription.ARRAY_INTERFACES.contains(typeDescription.asGenericType()); }