22 lines
577 B
Java
22 lines
577 B
Java
|
package com.github.dtschust.zork.objects;
|
||
|
|
||
|
import java.util.EnumSet;
|
||
|
import java.util.Optional;
|
||
|
|
||
|
public enum ZorkObjectTypes {
|
||
|
ROOM("room"),
|
||
|
ITEM("item"),
|
||
|
CONTAINER("container"),
|
||
|
CREATURE("creature");
|
||
|
|
||
|
private final String propertyName;
|
||
|
|
||
|
ZorkObjectTypes(final String propertyName) {
|
||
|
this.propertyName = propertyName;
|
||
|
}
|
||
|
|
||
|
public static Optional<ZorkObjectTypes> fromPropertyName(final String propertyName) {
|
||
|
return EnumSet.allOf(ZorkObjectTypes.class).stream().filter(e -> e.propertyName.equals(propertyName)).findFirst();
|
||
|
}
|
||
|
}
|