Skip to content

Commit

Permalink
fix #447 by allowing deserializeOr to return null
Browse files Browse the repository at this point in the history
  • Loading branch information
kashike committed Oct 20, 2021
1 parent 0eab517 commit ec3133b
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ static final class Instances {
return component;
}

@Override
public @Nullable Component deserializeOr(final @Nullable String input, final @Nullable Component fallback) {
if (input == null) return fallback;
final Component component = this.serializer().fromJson(input, Component.class);
if (component == null) return fallback;
return component;
}

@Override
public @NotNull String serialize(final @NotNull Component component) {
return this.serializer().toJson(component);
Expand Down

0 comments on commit ec3133b

Please sign in to comment.