in aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializer.java [217:255]
private <A> JSONObject serializeEventNotificationRecord(A eventNotificationRecord, String baseClassName) {
// reflect load all the classes we need
Class s3EntityClass = SerializeUtil.loadCustomerClass(baseClassName + "$S3Entity", classLoader);
Class requestParametersClass = SerializeUtil.loadCustomerClass(baseClassName + "$RequestParametersEntity", classLoader);
Class responseElementsClass = SerializeUtil.loadCustomerClass(baseClassName + "$ResponseElementsEntity", classLoader);
Class userIdentityClass = SerializeUtil.loadCustomerClass(baseClassName + "$UserIdentityEntity", classLoader);
// Workaround not to let maven shade plugin relocating string literals https://issues.apache.org/jira/browse/MSHADE-156
Class dateTimeClass = SerializeUtil.loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.DateTime", classLoader);
// serialize object
JSONObject jsonObject = new JSONObject();
Functions.R0<String> getAwsRegionMethod =
ReflectUtil.bindInstanceR0(eventNotificationRecord, "getAwsRegion", true, String.class);
jsonObject.put("awsRegion", getAwsRegionMethod.call());
Functions.R0<String> getEventNameMethod =
ReflectUtil.bindInstanceR0(eventNotificationRecord, "getEventName", true, String.class);
jsonObject.put("eventName", getEventNameMethod.call());
Functions.R0<String> getEventSourceMethod =
ReflectUtil.bindInstanceR0(eventNotificationRecord, "getEventSource", true, String.class);
jsonObject.put("eventSource", getEventSourceMethod.call());
Functions.R0<?> getEventTimeMethod =
ReflectUtil.bindInstanceR0(eventNotificationRecord, "getEventTime", true, dateTimeClass);
jsonObject.put("eventTime", SerializeUtil.serializeDateTime(getEventTimeMethod.call(), classLoader));
Functions.R0<String> getEventVersionMethod =
ReflectUtil.bindInstanceR0(eventNotificationRecord, "getEventVersion", true, String.class);
jsonObject.put("eventVersion", getEventVersionMethod.call());
Functions.R0<?> getRequestParametersMethod =
ReflectUtil.bindInstanceR0(eventNotificationRecord, "getRequestParameters", true, requestParametersClass);
jsonObject.put("requestParameters", serializeRequestParameters(getRequestParametersMethod.call()));
Functions.R0<?> getResponseElementsMethod =
ReflectUtil.bindInstanceR0(eventNotificationRecord, "getResponseElements", true, responseElementsClass);
jsonObject.put("responseElements", serializeResponseElements(getResponseElementsMethod.call()));
Functions.R0<?> getS3EntityMethod =
ReflectUtil.bindInstanceR0(eventNotificationRecord, "getS3", true, s3EntityClass);
jsonObject.put("s3", serializeS3Entity(getS3EntityMethod.call(), baseClassName));
Functions.R0<?> getUserIdentityMethod =
ReflectUtil.bindInstanceR0(eventNotificationRecord, "getUserIdentity", true, userIdentityClass);
jsonObject.put("userIdentity", serializeUserIdentity(getUserIdentityMethod.call()));
return jsonObject;
}