story.scheherazade.misc
Class PredicateFlavor

java.lang.Object
  extended by story.scheherazade.misc.PredicateFlavor
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, GenericType, RenderableObject

public class PredicateFlavor
extends java.lang.Object
implements GenericType, java.lang.Comparable, java.io.Serializable, RenderableObject

Manually implemented enum for types. Allows classes to specify types to one another by passing one of the fields of this class rather than a string. No public constructor.

Based (loosely) on http://xoot.org/index.php?name=Java+enum+classes

See Also:
Serialized Form

Field Summary
static PredicateFlavor Action
           
static PredicateFlavor Behavior
           
static PredicateFlavor Character
           
static PredicateFlavor Condition
           
static PredicateFlavor Location
           
static PredicateFlavor Modifier
           
static PredicateFlavor Prop
           
static PredicateFlavor Quality
           
 
Method Summary
static java.lang.String capitalize(java.lang.String in)
           
 int compareTo(java.lang.Object other)
           
 boolean equals(java.lang.Object other)
          Tests if one instance is the same as some other.
static PredicateFlavor get(int number)
          Return the corresponding PredicateFlavor for the given Unique ID (see getUniqueID).
static PredicateFlavor get(java.lang.String string)
          Static version of get() that gets around the Java restriction on static types in interfaces.
static ImmutableHashSet getAllTypes()
          Return a HashSet of every item in the enumeration.
 ImmutableHashSet getAllTypesNonStatically()
          Return a HashSet of every item in the enumeration.
 GenericType getAsGeneric(java.lang.String string)
          Return the corresponding PredicateFlavor for the given string as a GenericType object.
 int getUniqueID()
          Get a unique numerial ID for this type that goes from 0 to (numMembers() - 1).
static int numMembers()
          Get the number of members of this type.
 java.lang.StringBuffer render()
          Return the string equivalent of the PredicateFlavor with the type type, formatted with the dot operator that the command interpreter understands.
 java.lang.String toString()
          Return the string equivalent of the PredicateFlavor.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Condition

public static final PredicateFlavor Condition

Action

public static final PredicateFlavor Action

Modifier

public static final PredicateFlavor Modifier

Prop

public static final PredicateFlavor Prop

Location

public static final PredicateFlavor Location

Character

public static final PredicateFlavor Character

Behavior

public static final PredicateFlavor Behavior

Quality

public static final PredicateFlavor Quality
Method Detail

get

public static PredicateFlavor get(int number)
Return the corresponding PredicateFlavor for the given Unique ID (see getUniqueID).

Parameters:
number - Number index.

toString

public java.lang.String toString()
Return the string equivalent of the PredicateFlavor.

Specified by:
toString in interface GenericType
Overrides:
toString in class java.lang.Object

render

public java.lang.StringBuffer render()
Return the string equivalent of the PredicateFlavor with the type type, formatted with the dot operator that the command interpreter understands.

Specified by:
render in interface GenericType
Specified by:
render in interface RenderableObject

equals

public boolean equals(java.lang.Object other)
Tests if one instance is the same as some other.

Specified by:
equals in interface GenericType
Overrides:
equals in class java.lang.Object
Parameters:
other - Other PredicateFlavor to compare to.

getAllTypes

public static ImmutableHashSet getAllTypes()
Return a HashSet of every item in the enumeration.


getAllTypesNonStatically

public ImmutableHashSet getAllTypesNonStatically()
Return a HashSet of every item in the enumeration.

Specified by:
getAllTypesNonStatically in interface GenericType

getAsGeneric

public GenericType getAsGeneric(java.lang.String string)
Return the corresponding PredicateFlavor for the given string as a GenericType object.

Specified by:
getAsGeneric in interface GenericType

get

public static PredicateFlavor get(java.lang.String string)
Static version of get() that gets around the Java restriction on static types in interfaces.


compareTo

public int compareTo(java.lang.Object other)
              throws java.lang.ClassCastException
Specified by:
compareTo in interface java.lang.Comparable
Throws:
java.lang.ClassCastException

getUniqueID

public int getUniqueID()
Get a unique numerial ID for this type that goes from 0 to (numMembers() - 1).


numMembers

public static int numMembers()
Get the number of members of this type.


capitalize

public static java.lang.String capitalize(java.lang.String in)


Copyright © 2011 David K. Elson. All Rights Reserved.