sky.monome.event
Class GenericListenerWithArguments


java.lang.Object

  extended by sky.monome.event.GenericListenerWithArguments

Direct Known Subclasses:
AnalogListenerWithArguments, ButtonListenerWithArguments, FrameListenerWithArguments, SequencerListenerWithArguments

public abstract class GenericListenerWithArguments
extends java.lang.Object

Generic listener that can have internal arguments.

Author:
PJ Skyman

Field Summary
protected  java.lang.Object[] arguments
          Arguments of this listener.
 
Constructor Summary
protected GenericListenerWithArguments(java.lang.Object... arguments)
          Constructs a generic listener with specified arguments.
 
Method Summary
protected
<T> T
getArgument(java.lang.Class<T> clazz, int index)
          Returns the argument at the specified index.
protected
<T> T
getArgument(int index)
          Returns the argument at the specified index.
protected  java.lang.Object[] getArguments()
          Returns an array of arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arguments


protected final java.lang.Object[] arguments
Arguments of this listener.

Constructor Detail

GenericListenerWithArguments


protected GenericListenerWithArguments(java.lang.Object... arguments)
Constructs a generic listener with specified arguments.

Parameters:
arguments - Arguments of this generic listener.
Method Detail

getArguments


protected java.lang.Object[] getArguments()
Returns an array of arguments.

Returns:
An array of arguments.

getArgument


protected <T> T getArgument(int index)
Returns the argument at the specified index. The returned argument can be typed if you parametrize this call.

Type Parameters:
T - Type of the returned argument.
Parameters:
index - Index of the argument.
Returns:
The argument at the specified index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - When the index is out of bounds.
java.lang.ClassCastException - When the argument can't be typed to the specified type.

getArgument


protected <T> T getArgument(java.lang.Class<T> clazz,

                            int index)
Returns the argument at the specified index. The returned argument is typed to the specified type.

Type Parameters:
T - Type of the returned argument.
Parameters:
clazz - Class object that denotes the type of the returned argument.
index - Index of the argument.
Returns:
The argument at the specified index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - When the index is out of bounds.
java.lang.ClassCastException - When the argument can't be typed to the specified type.