jetbrains.buildServer.util
Class Option<Type>

java.lang.Object
  extended by jetbrains.buildServer.util.Option<Type>
Type Parameters:
Type - type of the option
Direct Known Subclasses:
BooleanOption, IntegerOption, StringOption

public abstract class Option<Type>
extends java.lang.Object

Represents a named option of given Type and some default value.


Constructor Summary
Option(java.lang.String key, Type defaultValue)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
static Option fromKey(java.lang.String key)
          Find option with given key in the registry of options
abstract  Type fromString(java.lang.String value)
          Option values are serialized to strings using toString() call.
 Type getDefaultValue()
           
 java.lang.String getKey()
           
 int hashCode()
           
 java.lang.String toString()
           
abstract  java.lang.String toString(Type value)
          Serialize option value to string
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Option

public Option(@NonNls@NotNull
              java.lang.String key,
              @NotNull
              Type defaultValue)
Parameters:
key - name of the parameter. Used in equals and hashCode
defaultValue - default value for this option, if not specified
Method Detail

fromString

public abstract Type fromString(java.lang.String value)
Option values are serialized to strings using toString() call. To restore option value from string this method is used

Parameters:
value - serialized option value (Type#toString() method is used for serialization)
Returns:
unserialized value

toString

public abstract java.lang.String toString(Type value)
Serialize option value to string

Parameters:
value - value to serialize
Returns:
serialized option value

fromKey

@Nullable
public static Option fromKey(java.lang.String key)
Find option with given key in the registry of options

Parameters:
key - option key, see getKey()
Returns:
option for this key

getKey

@NotNull
public java.lang.String getKey()
Returns:
key of the option (non-displayable)

getDefaultValue

@NotNull
public Type getDefaultValue()
Returns:
default value of the option

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object