generateGetter method
Generates code that gets a representation of the type from an expression
representing an XmlElement
.
The representation of the type should be a String or XmlElement
that can be deserialized by a SerializerGenerator.
An implementation to get a representation of the type from the text of an XML element could be as simple as:
String generateGetter(String expression) => '$expression.getText()';
Implementation
@override
String generateGetter(String expression) {
final buffer = StringBuffer(expression);
buffer.write('.getElements(\'$_name\'');
if (_namespace != null) {
buffer.write(', namespace: \'$_namespace\'');
}
buffer.write(')');
if (!_isNullable) {
buffer.write('!');
}
return buffer.toString();
}