org.jboss.xnio.channels
Class PlainChannelOption<T>

java.lang.Object
  extended by org.jboss.xnio.channels.PlainChannelOption<T>
All Implemented Interfaces:
java.io.Serializable, ChannelOption<T>

public class PlainChannelOption<T>
extends java.lang.Object
implements ChannelOption<T>

A plain channel option implementation. Use to easily define channel options.

See Also:
Serialized Form

Constructor Summary
PlainChannelOption(java.lang.String name, java.lang.Class<T> type)
          Basic constructor.
 
Method Summary
static
<T> ChannelOption<T>
createOption(java.lang.String name, java.lang.Class<T> type)
          Convenience factory method.
 boolean equals(java.lang.Object o)
          Check equality with another object.
 java.lang.String getName()
          Get the option name.
 java.lang.Class<T> getType()
          Get option type.
 int hashCode()
          Calculate the hashCode.
 java.lang.String toString()
          Get a simple string representation of this option.
 T valueOf(java.lang.String string)
          Get the value of the given string as the value type of this channel option, if possible.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PlainChannelOption

public PlainChannelOption(java.lang.String name,
                          java.lang.Class<T> type)
Basic constructor.

Parameters:
name - the option name; must not be null
type - the option type; must not be null
Method Detail

createOption

public static <T> ChannelOption<T> createOption(java.lang.String name,
                                                java.lang.Class<T> type)
Convenience factory method. Create a channel option. Infers type from context.

Parameters:
name - the option name
type - the value type
Returns:
the new option

equals

public boolean equals(java.lang.Object o)
Check equality with another object. Two options are equal if the name and the type are both equal.

Specified by:
equals in interface ChannelOption<T>
Overrides:
equals in class java.lang.Object
Parameters:
o - the other object
Returns:
true if the the other object is equal to this one

hashCode

public int hashCode()
Calculate the hashCode. See ChannelOption.hashCode().

Specified by:
hashCode in interface ChannelOption<T>
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code

getName

public java.lang.String getName()
Get the option name.

Specified by:
getName in interface ChannelOption<T>
Returns:
the option name

getType

public java.lang.Class<T> getType()
Get option type.

Specified by:
getType in interface ChannelOption<T>
Returns:
the option type

toString

public java.lang.String toString()
Get a simple string representation of this option.

Specified by:
toString in interface ChannelOption<T>
Overrides:
toString in class java.lang.Object
Returns:
a representation of this option

valueOf

public T valueOf(java.lang.String string)
          throws java.lang.IllegalArgumentException
Get the value of the given string as the value type of this channel option, if possible.

Specified by:
valueOf in interface ChannelOption<T>
Parameters:
string - the string representation of the value
Returns:
the value
Throws:
java.lang.IllegalArgumentException - if the value is not valid for this option