DynamicClassLoader classLoader)
{
boolean grouped = accumulatorInterface == GroupedAccumulator.class;
boolean approximate = metadata.isApproximate();
ClassDefinition definition = new ClassDefinition(
a(PUBLIC, FINAL),
makeClassName(metadata.getName() + accumulatorInterface.getSimpleName()),
type(Object.class),
type(accumulatorInterface));
CallSiteBinder callSiteBinder = new CallSiteBinder();
AccumulatorStateSerializer<?> stateSerializer = metadata.getStateSerializer();
AccumulatorStateFactory<?> stateFactory = metadata.getStateFactory();
FieldDefinition stateSerializerField = definition.declareField(a(PRIVATE, FINAL), "stateSerializer", AccumulatorStateSerializer.class);
FieldDefinition stateFactoryField = definition.declareField(a(PRIVATE, FINAL), "stateFactory", AccumulatorStateFactory.class);
FieldDefinition inputChannelsField = definition.declareField(a(PRIVATE, FINAL), "inputChannels", type(List.class, Integer.class));
FieldDefinition maskChannelField = definition.declareField(a(PRIVATE, FINAL), "maskChannel", type(Optional.class, Integer.class));
FieldDefinition sampleWeightChannelField = null;
FieldDefinition confidenceField = null;
if (approximate) {
sampleWeightChannelField = definition.declareField(a(PRIVATE, FINAL), "sampleWeightChannel", type(Optional.class, Integer.class));
confidenceField = definition.declareField(a(PRIVATE, FINAL), "confidence", double.class);
}
FieldDefinition stateField = definition.declareField(a(PRIVATE, FINAL), "state", grouped ? stateFactory.getGroupedStateClass() : stateFactory.getSingleStateClass());
// Generate constructor
generateConstructor(
definition,
stateSerializerField,