ExtractMethodOptions.fromJson constructor
ExtractMethodOptions.fromJson(
- JsonDecoder jsonDecoder,
- String jsonPath,
- Object? json
)
Implementation
factory ExtractMethodOptions.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
json ??= {};
if (json is Map) {
String returnType;
if (json.containsKey('returnType')) {
returnType = jsonDecoder.decodeString(
'$jsonPath.returnType', json['returnType']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'returnType');
}
bool createGetter;
if (json.containsKey('createGetter')) {
createGetter = jsonDecoder.decodeBool(
'$jsonPath.createGetter', json['createGetter']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'createGetter');
}
String name;
if (json.containsKey('name')) {
name = jsonDecoder.decodeString('$jsonPath.name', json['name']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'name');
}
List<RefactoringMethodParameter> parameters;
if (json.containsKey('parameters')) {
parameters = jsonDecoder.decodeList(
'$jsonPath.parameters',
json['parameters'],
(String jsonPath, Object? json) =>
RefactoringMethodParameter.fromJson(
jsonDecoder, jsonPath, json));
} else {
throw jsonDecoder.mismatch(jsonPath, 'parameters');
}
bool extractAll;
if (json.containsKey('extractAll')) {
extractAll =
jsonDecoder.decodeBool('$jsonPath.extractAll', json['extractAll']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'extractAll');
}
return ExtractMethodOptions(
returnType, createGetter, name, parameters, extractAll);
} else {
throw jsonDecoder.mismatch(jsonPath, 'extractMethod options', json);
}
}