FieldModel eventNameConstant = new FieldModel("NAME", "String", CompilerUtils.quote(event.name));
eventNameConstant.setStatic(true);
eventNameConstant.setAsdoc(MessageFormat.format("This constant defines the value of the <code>type</code> property of the event object\nfor a <code>{0}</code> event.\n * @eventType {0}", event.name));
extAsClass.addMember(eventNameConstant);
MethodModel constructorModel = extAsClass.createConstructor();
constructorModel.addParam(new ParamModel("arguments", "Array"));
StringBuilder propertyAssignments = new StringBuilder();
for (int i = 0; i < event.params.size(); i++) {
Param param = event.params.get(i);
// add assignment to constructor body:
if (i > 0) {
propertyAssignments.append("\n ");
}
propertyAssignments.append(String.format("this['%s'] = arguments[%d];", convertName(param.name), i));
// add getter method:
MethodModel property = new MethodModel(MethodType.GET, convertName(param.name), convertType(param.type));
property.setAsdoc(toAsDoc(param.doc));
extAsClass.addMember(property);
}
constructorModel.setBody(propertyAssignments.toString());