Skip to content

Commit

Permalink
fix: some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eschrewe committed Dec 6, 2023
1 parent d9fd0a8 commit 0046fa1
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Arrays;
import java.util.Optional;

/**
Expand Down Expand Up @@ -77,7 +76,8 @@ public enum ItemUnitEnumeration {

@JsonCreator
static ItemUnitEnumeration enumDeserializationConstructor(String value) {
return fromValue(value).orElseThrow(() -> new IllegalArgumentException(
return Optional.of(ItemUnitEnumeration.valueOf(ItemUnitEnumeration.class, value)).orElseThrow(
() -> new IllegalArgumentException(
"Tried to parse value \"" + value + "\", but there is no enum field like that in ItemUnitEnumeration"));
}

Expand All @@ -86,8 +86,4 @@ public String getValue() {
return value;
}

public static Optional<ItemUnitEnumeration> fromValue(String value) {
return Arrays.stream(ItemUnitEnumeration.values()).filter(enumValue -> enumValue.getValue().equals(value)).findFirst();
}

}

0 comments on commit 0046fa1

Please sign in to comment.