writeClassEncode method
void
writeClassEncode(
- JavaOptions generatorOptions,
- Root root,
- Indent indent,
- Class classDefinition, {
- required String dartPackageName,
override
Writes a single class encode method to indent
.
Implementation
@override
void writeClassEncode(
JavaOptions generatorOptions,
Root root,
Indent indent,
Class classDefinition, {
required String dartPackageName,
}) {
indent.newln();
indent.writeln('@NonNull');
indent.write('ArrayList<Object> toList() ');
indent.addScoped('{', '}', () {
indent.writeln(
'ArrayList<Object> toListResult = new ArrayList<>(${classDefinition.fields.length});');
for (final NamedType field
in getFieldsInSerializationOrder(classDefinition)) {
indent.writeln('toListResult.add(${field.name});');
}
indent.writeln('return toListResult;');
});
}