feature: add Unknown type

This commit is contained in:
Kadir Sirimsi 2025-02-10 16:14:07 +01:00
parent 981180fdb0
commit 8879189e92
No known key found for this signature in database
GPG Key ID: A21C0144C2D2A134

View File

@ -5,7 +5,8 @@ import java.util.Arrays;
public enum ItemType { public enum ItemType {
AgedBrie("Aged Brie"), AgedBrie("Aged Brie"),
BackstagePass("Backstage passes to a TAFKAL80ETC concert"), BackstagePass("Backstage passes to a TAFKAL80ETC concert"),
Sulfuras("Sulfuras, Hand of Ragnaros"); Sulfuras("Sulfuras, Hand of Ragnaros"),
Unknown("Unknown");
private final String name; private final String name;
@ -21,6 +22,6 @@ public enum ItemType {
return Arrays.stream(ItemType.values()) return Arrays.stream(ItemType.values())
.filter(itemType -> itemType.getName().equals(name)) .filter(itemType -> itemType.getName().equals(name))
.findFirst() .findFirst()
.orElseThrow( () -> new IllegalArgumentException(name)); .orElse(Unknown);
} }
} }