config property
Deserialize a Config
from an annotation, such as RestSerializable
.
Implementation
@override
RestSerializableExtended get config {
if (reader.peek(configKey) == null) {
return const RestSerializableExtended();
}
final fieldRenameIndex =
withinConfigKey('fieldRename')?.objectValue.getField('index')?.toIntValue();
final fieldRename = fieldRenameIndex != null ? FieldRename.values[fieldRenameIndex] : null;
final function = withinConfigKey('requestTransformer')?.objectValue.toFunctionValue();
var functionName = function?.enclosingElement.name;
if (function is ConstructorElement) {
functionName = '$functionName.new';
}
return RestSerializableExtended(
fieldRename: fieldRename ?? RestSerializable.defaults.fieldRename,
nullable: withinConfigKey('nullable')?.boolValue ?? RestSerializable.defaults.nullable,
requestName: functionName,
);
}