+
+ private enum ConstructorImplementation implements Implementation {
+ INSTANCE;
+
+ private static final StackManipulation INSTANT_ARG = MethodVariableAccess.REFERENCE.loadFrom(3);
+ private static final StackManipulation LOAD_CTOR_ARGS;
+
+ static {
+ try {
+ LOAD_CTOR_ARGS = MethodVariableAccess.allArgumentsOf(new MethodDescription.ForLoadedConstructor(
+ AugmentableCodecDataObject.class.getDeclaredConstructor(DataObjectCodecContext.class,
+ NormalizedNodeContainer.class)));
+ } catch (NoSuchMethodException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
+ @Override
+ public InstrumentedType prepare(final InstrumentedType instrumentedType) {
+ return instrumentedType;
+ }
+
+ @Override
+ public ByteCodeAppender appender(final Target implementationTarget) {
+ final TypeDescription instrumentedType = implementationTarget.getInstrumentedType();
+ final InGenericShape superCtor = instrumentedType.getSuperClass().getDeclaredMethods()
+ .filter(ElementMatchers.isConstructor()).getOnly();
+
+ return new ByteCodeAppender.Simple(
+ ByteBuddyUtils.THIS,
+ LOAD_CTOR_ARGS,
+ MethodInvocation.invoke(superCtor),
+ ByteBuddyUtils.THIS,
+ INSTANT_ARG,
+ ByteBuddyUtils.putField(instrumentedType, INSTANT_FIELD),
+ MethodReturn.VOID);
+ }
+ }
+
+ private enum EventInstantImplementation implements Implementation {
+ INSTANCE;
+
+ @Override
+ public InstrumentedType prepare(final InstrumentedType instrumentedType) {
+ return instrumentedType;
+ }
+
+ @Override
+ public ByteCodeAppender appender(final Target implementationTarget) {
+ return new ByteCodeAppender.Simple(
+ ByteBuddyUtils.THIS,
+ ByteBuddyUtils.getField(implementationTarget.getInstrumentedType(), INSTANT_FIELD),
+ MethodReturn.REFERENCE);
+ }
+ }
+}