Skip to content

Commit

Permalink
chore: change aliases from List to Set
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfccp committed Nov 26, 2024
1 parent 6c25d85 commit 5ec7cee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions json_annotation/lib/src/json_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class JsonValue {
/// Optional values that can be used when deserializing.
///
/// The elements of [aliases] must be either [String] or [int].
final List<Object?> aliases;
final Set<Object?> aliases;

const JsonValue(this.value, {this.aliases = const []});
const JsonValue(this.value, {this.aliases = const {}});
}
6 changes: 3 additions & 3 deletions json_serializable/lib/src/enum_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Map<Object?, FieldElement>? _enumAliases(
jsonEnum: jsonEnum,
targetType: targetType,
): field,
for (final alias in _generateAlias(field: field, targetType: targetType))
for (final alias in _generateAliases(field: field, targetType: targetType))
alias: field,
},
};
Expand Down Expand Up @@ -192,7 +192,7 @@ Object? _generateEntry({
}
}

List<Object?> _generateAlias({
List<Object?> _generateAliases({
required FieldElement field,
required DartType targetType,
}) {
Expand All @@ -208,7 +208,7 @@ List<Object?> _generateAlias({

if (valueReader.validAliasesType) {
return [
for (final value in valueReader.listValue)
for (final value in valueReader.setValue)
ConstantReader(value).literalValue,
];
} else {
Expand Down

0 comments on commit 5ec7cee

Please sign in to comment.