de.matthiasmann.twl.renderer
Class AnimationState.StateKey

java.lang.Object
  extended by de.matthiasmann.twl.renderer.AnimationState.StateKey
Enclosing interface:
AnimationState

public static final class AnimationState.StateKey
extends java.lang.Object

An animation state key which maps each animation state name to an unique ID. This allows to implement faster lookups based on the unique ID instead of performing a string lookup.


Method Summary
 boolean equals(java.lang.Object obj)
           
static AnimationState.StateKey get(int id)
          Returns the StateKey for the specified id.
static AnimationState.StateKey get(java.lang.String name)
          Returns the StateKey for the specified name.
 int getID()
          The unique ID of this StateKey.
 java.lang.String getName()
          The name of this animation state key
static int getNumStateKeys()
           
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()
The name of this animation state key

Returns:
the name

getID

public int getID()
The unique ID of this StateKey. The first StateKey has ID 0.

Returns:
the unique ID

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

get

public static AnimationState.StateKey get(java.lang.String name)
Returns the StateKey for the specified name. The StateKey is created if it didn't exist.

Parameters:
name - the name to look up
Returns:
the StateKey - never null.
Throws:
java.lang.IllegalArgumentException - if name is empty
java.lang.NullPointerException - if name is null

get

public static AnimationState.StateKey get(int id)
Returns the StateKey for the specified id.

Parameters:
id - the ID to lookup
Returns:
the StateKey
Throws:
java.lang.IndexOutOfBoundsException - if the ID is invalid

getNumStateKeys

public static int getNumStateKeys()