org.crsh.plugin
Class PropertyDescriptor<T>

java.lang.Object
  extended by org.crsh.plugin.PropertyDescriptor<T>

public abstract class PropertyDescriptor<T>
extends Object


Field Summary
static Map<String,PropertyDescriptor<?>> ALL
          .
 T defaultValue
          .
 String description
          .
private static Map<String,PropertyDescriptor<?>> INTERNAL_ALL
          .
 String name
          .
 boolean secret
          .
static String SECRET_DISPLAY_VALUE
          The display value returned when a property is secret.
 Class<T> type
          .
static PropertyDescriptor<Integer> VFS_REFRESH_PERIOD
          .
static PropertyDescriptor<TimeUnit> VFS_REFRESH_UNIT
          .
 
Constructor Summary
protected PropertyDescriptor(Class<T> type, String name, T defaultValue, String description)
          Create a new property descriptor.
protected PropertyDescriptor(Class<T> type, String name, T defaultValue, String description, boolean secret)
          Create a new property descriptor.
 
Method Summary
static PropertyDescriptor<Integer> create(String name, Integer defaultValue, String description)
           
static PropertyDescriptor<Integer> create(String name, Integer defaultValue, String description, boolean secret)
           
static PropertyDescriptor<List> create(String name, List defaultValue, String description)
           
static PropertyDescriptor<List> create(String name, List defaultValue, String description, boolean secret)
           
static PropertyDescriptor<String> create(String name, String defaultValue, String description)
           
static PropertyDescriptor<String> create(String name, String defaultValue, String description, boolean secret)
           
protected abstract  T doParse(String s)
          Implements the real parsing, the string argument must nto be null.
 boolean equals(Object obj)
           
 String getDefaultDisplayValue()
           
 T getDefaultValue()
           
 String getDescription()
           
 String getName()
           
 Class<T> getType()
           
 T parse(String s)
          Parse a string representation of a value and returns the corresponding typed value.
 Property<T> toProperty(String s)
          Parse a string representation of a value and returns the correspondig property value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SECRET_DISPLAY_VALUE

public static final String SECRET_DISPLAY_VALUE
The display value returned when a property is secret.

See Also:
Constant Field Values

INTERNAL_ALL

private static final Map<String,PropertyDescriptor<?>> INTERNAL_ALL
.


ALL

public static final Map<String,PropertyDescriptor<?>> ALL
.


VFS_REFRESH_UNIT

public static final PropertyDescriptor<TimeUnit> VFS_REFRESH_UNIT
.


VFS_REFRESH_PERIOD

public static final PropertyDescriptor<Integer> VFS_REFRESH_PERIOD
.


type

public final Class<T> type
.


name

public final String name
.


defaultValue

public final T defaultValue
.


description

public final String description
.


secret

public final boolean secret
.

Constructor Detail

PropertyDescriptor

protected PropertyDescriptor(Class<T> type,
                             String name,
                             T defaultValue,
                             String description)
                      throws NullPointerException
Create a new property descriptor.

Parameters:
type - the property type
name - the property name
defaultValue - the default value
description - the description
Throws:
NullPointerException - if the type, name or description is null

PropertyDescriptor

protected PropertyDescriptor(Class<T> type,
                             String name,
                             T defaultValue,
                             String description,
                             boolean secret)
                      throws NullPointerException
Create a new property descriptor.

Parameters:
type - the property type
name - the property name
defaultValue - the default value
description - the description
secret - the value is secret (like a password)
Throws:
NullPointerException - if the type, name or description is null
Method Detail

create

public static PropertyDescriptor<String> create(String name,
                                                String defaultValue,
                                                String description,
                                                boolean secret)

create

public static PropertyDescriptor<String> create(String name,
                                                String defaultValue,
                                                String description)

create

public static PropertyDescriptor<Integer> create(String name,
                                                 Integer defaultValue,
                                                 String description,
                                                 boolean secret)

create

public static PropertyDescriptor<Integer> create(String name,
                                                 Integer defaultValue,
                                                 String description)

create

public static PropertyDescriptor<List> create(String name,
                                              List defaultValue,
                                              String description,
                                              boolean secret)

create

public static PropertyDescriptor<List> create(String name,
                                              List defaultValue,
                                              String description)

getName

public final String getName()

getDescription

public final String getDescription()

getType

public final Class<T> getType()

getDefaultValue

public final T getDefaultValue()

getDefaultDisplayValue

public final String getDefaultDisplayValue()

parse

public final T parse(String s)
              throws NullPointerException,
                     IllegalArgumentException
Parse a string representation of a value and returns the corresponding typed value.

Parameters:
s - the string to parse
Returns:
the corresponding value
Throws:
NullPointerException - if the argument is null
IllegalArgumentException - if the string value cannot be parsed for some reason

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toProperty

public final Property<T> toProperty(String s)
                             throws NullPointerException,
                                    IllegalArgumentException
Parse a string representation of a value and returns the correspondig property value.

Parameters:
s - the string to parse
Returns:
the corresponding property
Throws:
NullPointerException - if the argument is null
IllegalArgumentException - if the string value cannot be parsed for some reason

doParse

protected abstract T doParse(String s)
                      throws Exception
Implements the real parsing, the string argument must nto be null. The returned value must not be null instead an exception must be thrown.

Parameters:
s - the string to parse
Returns:
the related value
Throws:
Exception - any exception that would prevent parsing to hapen

toString

public final String toString()
Overrides:
toString in class Object


Copyright © 2015 eXo Platform SAS. All Rights Reserved.