writeClassDecode method
void
writeClassDecode(
- JavaOptions generatorOptions,
- Root root,
- Indent indent,
- Class classDefinition, {
- required String dartPackageName,
override
Writes a single class decode method to indent
.
Implementation
@override
void writeClassDecode(
JavaOptions generatorOptions,
Root root,
Indent indent,
Class classDefinition, {
required String dartPackageName,
}) {
indent.newln();
indent.write(
'static @NonNull ${classDefinition.name} fromList(@NonNull ArrayList<Object> ${varNamePrefix}list) ');
indent.addScoped('{', '}', () {
const String result = 'pigeonResult';
indent.writeln(
'${classDefinition.name} $result = new ${classDefinition.name}();');
enumerate(getFieldsInSerializationOrder(classDefinition),
(int index, final NamedType field) {
final String fieldVariable = field.name;
final String setter = _makeSetter(field);
indent.writeln(
'Object $fieldVariable = ${varNamePrefix}list.get($index);');
indent
.writeln('$result.$setter(${_castObject(field, fieldVariable)});');
});
indent.writeln('return $result;');
});
}