T
- the option value typepublic abstract class Option<T> extends Object implements Serializable
public static final
members in order to support serialization.Modifier and Type | Class and Description |
---|---|
static class |
Option.SetBuilder
A builder for an immutable option set.
|
Modifier and Type | Method and Description |
---|---|
abstract T |
cast(Object o)
Return the given object as the type of this option.
|
T |
cast(Object o,
T defaultVal)
Return the given object as the type of this option.
|
static Option<?> |
fromString(String name,
ClassLoader classLoader)
Get an option from a string name, using the given classloader.
|
String |
getName()
Get the name of this option.
|
abstract T |
parseValue(String string,
ClassLoader classLoader)
Parse a string value for this option.
|
protected Object |
readResolve()
Resolve this instance for serialization.
|
static <T> Option<Sequence<T>> |
sequence(Class<?> declClass,
String name,
Class<T> elementType)
Create an option with a sequence type.
|
static Option.SetBuilder |
setBuilder()
Create a builder for an immutable option set.
|
static <T> Option<T> |
simple(Class<?> declClass,
String name,
Class<T> type)
Create an option with a simple type.
|
String |
toString()
Get a human-readable string representation of this object.
|
static <T> Option<Class<? extends T>> |
type(Class<?> declClass,
String name,
Class<T> declType)
Create an option with a class type.
|
static <T> Option<Sequence<Class<? extends T>>> |
typeSequence(Class<?> declClass,
String name,
Class<T> elementDeclType)
Create an option with a sequence-of-types type.
|
public static <T> Option<T> simple(Class<?> declClass, String name, Class<T> type)
declClass
- the declaring class of the optionname
- the (field) name of this optiontype
- the class of the value associated with this optionpublic static <T> Option<Sequence<T>> sequence(Class<?> declClass, String name, Class<T> elementType)
declClass
- the declaring class of the optionname
- the (field) name of this optionelementType
- the class of the sequence element value associated with this optionpublic static <T> Option<Class<? extends T>> type(Class<?> declClass, String name, Class<T> declType)
T
- the type of the class object givendeclClass
- the declaring class of the optionname
- the (field) name of this optiondeclType
- the class object for the type of the class object givenpublic static <T> Option<Sequence<Class<? extends T>>> typeSequence(Class<?> declClass, String name, Class<T> elementDeclType)
T
- the type of the sequence element class object givendeclClass
- the declaring class of the optionname
- the (field) name of this optionelementDeclType
- the class object for the type of the sequence element class object givenpublic String getName()
public String toString()
public static Option<?> fromString(String name, ClassLoader classLoader) throws IllegalArgumentException
null
, the bootstrap
classloader will be used.name
- the option stringclassLoader
- the class loaderIllegalArgumentException
- if the given option name is not validpublic abstract T cast(Object o) throws ClassCastException
o
- the object to castClassCastException
- if the object is not of a compatible typepublic final T cast(Object o, T defaultVal) throws ClassCastException
o
- the object to castdefaultVal
- the value to return if o
is null
ClassCastException
- if the object is not of a compatible typepublic abstract T parseValue(String string, ClassLoader classLoader) throws IllegalArgumentException
string
- the stringclassLoader
- the class loader to use to parse the valueIllegalArgumentException
- if the argument could not be parsedprotected final Object readResolve() throws ObjectStreamException
ObjectStreamException
- if the object could not be resolvedpublic static Option.SetBuilder setBuilder()
Copyright © 2016 JBoss by Red Hat. All rights reserved.