com.alogient.cameleon.extension.wicket.ui.component
Class SelectChoice<T extends Serializable>

java.lang.Object
  extended by com.alogient.cameleon.extension.wicket.ui.component.SelectChoice<T>
Type Parameters:
T - class of key
All Implemented Interfaces:
Serializable, Comparable<SelectChoice<T>>
Direct Known Subclasses:
IntegerSelectChoice

public abstract class SelectChoice<T extends Serializable>
extends Object
implements Serializable, Comparable<SelectChoice<T>>

Based class for representing a select list choice. Represents a user-defined type T and its display value.

Can be sorted via Collections.sort if T implements Comparable.

See Also:
Serialized Form

Constructor Summary
SelectChoice(T key, String display)
           
 
Method Summary
 int compareTo(SelectChoice<T> o)
          Implementation of Comparable.
 String getDisplay()
           
 T getKey()
           
 String getKeyAsString()
           
 void setDisplay(String display)
          Set the display value
 void setKey(T key)
          Set the key value
 String toString()
          Return String version of key so returns a sensible value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectChoice

public SelectChoice(T key,
                    String display)
Method Detail

getDisplay

public String getDisplay()
Returns:
display value

setDisplay

public void setDisplay(String display)
Set the display value

Parameters:
display - value to set

getKey

public T getKey()
Returns:
key value

setKey

public void setKey(T key)
Set the key value

Parameters:
key - value to set

getKeyAsString

public String getKeyAsString()
Returns:
return String representation of the key

toString

public String toString()
Return String version of key so returns a sensible value. Useful if storing the value in PageParameters.

Overrides:
toString in class Object
Returns:
getKeyAsString()

compareTo

public int compareTo(SelectChoice<T> o)
Implementation of Comparable.

Specified by:
compareTo in interface Comparable<SelectChoice<T extends Serializable>>
Parameters:
o - the item to compare
Returns:
this.key.compareTo(o.key)
Throws:
UnsupportedOperationException - if the underlying key class does not implement Comparable


Copyright © 2011 Alogient. All Rights Reserved.