public class ObjectEnum<T>
extends java.lang.Object
implements java.lang.Iterable<T>
This is useful if you want the flexibility of a modern Java enum, but don't want to prevent the creation of additional members dynamically.
Modifier and Type | Field and Description |
---|---|
protected com.google.common.collect.BiMap<T,java.lang.String> |
members |
Constructor and Description |
---|
ObjectEnum(java.lang.Class<T> fieldType)
Registers every declared integer field.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDeclaredName(T member)
Retrieve the name of the given member.
|
boolean |
hasMember(T member)
Determines whether or not the given member has been registered to this enum.
|
java.util.Iterator<T> |
iterator() |
protected void |
registerAll(java.lang.Class<T> fieldType)
Registers every public assignable static field as a member.
|
boolean |
registerMember(T instance,
java.lang.String name)
Registers a member if its not present.
|
T |
valueOf(java.lang.String name)
Retrieve a member by name,
|
java.util.Set<T> |
values()
Retrieve every registered member.
|
protected com.google.common.collect.BiMap<T,java.lang.String> members
public ObjectEnum(java.lang.Class<T> fieldType)
protected void registerAll(java.lang.Class<T> fieldType)
public boolean registerMember(T instance, java.lang.String name)
instance
- - member instance.name
- - name of member.public boolean hasMember(T member)
member
- - the member to check.public T valueOf(java.lang.String name)
name
- - name of member to retrieve.public java.lang.String getDeclaredName(T member)
member
- - the member to retrieve.public java.util.Set<T> values()