mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-09 11:41:37 +00:00
feature: add Unknown type
This commit is contained in:
parent
981180fdb0
commit
8879189e92
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user