XNIO version 1.2.0.GA

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

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

public class PlainChannelOption<T>
extends Object
implements ChannelOption<T>

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

See Also:
Serialized Form

Constructor Summary
PlainChannelOption(String name, Class<T> type)
          Basic constructor.
 
Method Summary
static
<T> ChannelOption<T>
createOption(String name, Class<T> type)
          Convenience factory method.
 boolean equals(Object o)
          Check equality with another object.
 String getName()
          Get the option name.
 Class<T> getType()
          Get option type.
 int hashCode()
          Calculate the hashCode.
 String toString()
          Get a simple string representation of this option.
 T valueOf(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(String name,
                          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(String name,
                                                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(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 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 Object
Returns:
the hash code

getName

public String getName()
Get the option name.

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

getType

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

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

toString

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

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

valueOf

public T valueOf(String string)
          throws 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:
IllegalArgumentException - if the value is not valid for this option

XNIO version 1.2.0.GA

Copyright © 2008 JBoss, a division of Red Hat, Inc.