chemaxon.marvin.services
Class ServiceArgument<T>

java.lang.Object
  extended by chemaxon.marvin.services.ServiceArgument<T>
Type Parameters:
T - the type of the argument
Direct Known Subclasses:
DynamicArgument

public class ServiceArgument<T>
extends java.lang.Object

Describes an argument passed to services

Since:
5.6
Author:
Istvan Rabel

Field Summary
protected  java.lang.String alias
          the alias of the argument
protected  boolean constant
          field indicates constant argument
protected  java.lang.String name
          the name of the argument
protected  java.lang.Class<T> type
          type of the argument
protected  T value
          value of the argument
 
Constructor Summary
protected ServiceArgument(java.lang.Class<T> type, T value)
          Constructs a service argument with specified type and value
protected ServiceArgument(java.lang.Class<T> type, T value, boolean constant)
          Constructs a service argument with specified type and value
 
Method Summary
static
<T> ServiceArgument<T>
createArgument(java.lang.String name, T value)
          Returns a service argument based on value
static
<T> ServiceArgument<T>
createArgument(T value)
          Returns a service argument based on value
static
<T> ServiceArgument<T>
createArgumentAs(java.lang.String name, T value, java.lang.Class<T> type)
          Returns a service argument based on value and type
static
<T> ServiceArgument<T>
createArgumentAs(T value, java.lang.Class<T> type)
          Returns a service argument based on value and type
static ServiceArgument<?> createConstantFromString(java.lang.String value, java.lang.Class<?> argumentClass)
          Creates a ServiceArgument constant based on string value and argument type.
 java.lang.String getAlias()
          Returns the argument alias.
 java.lang.String getName()
          Returns the name of the argument
 java.lang.Class<T> getType()
          Returns the argument type
 T getValue()
          Returns the argument value
 boolean isValid()
          Returns true if service argument is valid
 void setAlias(java.lang.String alias)
          Sets the argument alias.
 void setName(java.lang.String name)
          Sets the name of the argument
 void setType(java.lang.Class<T> argumentType)
          Sets the class of the argument
 void setValue(T value)
          Sets the service argument value
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

protected java.lang.Class<T> type
type of the argument


value

protected T value
value of the argument


constant

protected final boolean constant
field indicates constant argument


name

protected java.lang.String name
the name of the argument


alias

protected java.lang.String alias
the alias of the argument

Constructor Detail

ServiceArgument

protected ServiceArgument(java.lang.Class<T> type,
                          T value)
Constructs a service argument with specified type and value

Parameters:
type - the argument type
value - the argument value

ServiceArgument

protected ServiceArgument(java.lang.Class<T> type,
                          T value,
                          boolean constant)
Constructs a service argument with specified type and value

Parameters:
type - the argument type
value - the argument value
constant - the constant flag
Method Detail

createArgument

public static <T> ServiceArgument<T> createArgument(T value)
Returns a service argument based on value

Type Parameters:
T - the argument type
Parameters:
value - the argument value
Returns:
a constant service argument based on value

createArgument

public static <T> ServiceArgument<T> createArgument(java.lang.String name,
                                                    T value)
Returns a service argument based on value

Type Parameters:
T - the argument type
Parameters:
name - argument name
value - the argument value
Returns:
a constant service argument based on value

createArgumentAs

public static <T> ServiceArgument<T> createArgumentAs(T value,
                                                      java.lang.Class<T> type)
Returns a service argument based on value and type

Type Parameters:
T - the argument type
Parameters:
value - the argument value
type - the argument type
Returns:
a constant service argument based on value

createArgumentAs

public static <T> ServiceArgument<T> createArgumentAs(java.lang.String name,
                                                      T value,
                                                      java.lang.Class<T> type)
Returns a service argument based on value and type

Type Parameters:
T - the argument type
Parameters:
name - the argument name
value - the argument value
type - the argument type
Returns:
a constant service argument based on value

getType

public java.lang.Class<T> getType()
Returns the argument type

Returns:
the argument type

setType

public void setType(java.lang.Class<T> argumentType)
Sets the class of the argument

Parameters:
argumentType - the argument class

getValue

public T getValue()
Returns the argument value

Returns:
the argument value

setValue

public void setValue(T value)
Sets the service argument value

Parameters:
value - the new value

isValid

public boolean isValid()
Returns true if service argument is valid

Returns:
true if service argument is valid

getName

public java.lang.String getName()
Returns the name of the argument

Returns:
the name of the argument

setName

public void setName(java.lang.String name)
Sets the name of the argument

Parameters:
name - the new argument name

getAlias

public java.lang.String getAlias()
Returns the argument alias. Aliases may be used to call services in a user friendly way by parsing user input.

Returns:
the argument alias or null if no alias set

setAlias

public void setAlias(java.lang.String alias)
Sets the argument alias. Aliases may be used to call services in a user friendly way by parsing user input.

Parameters:
alias - the new alias

toString

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

createConstantFromString

public static ServiceArgument<?> createConstantFromString(java.lang.String value,
                                                          java.lang.Class<?> argumentClass)
Creates a ServiceArgument constant based on string value and argument type.
Supported types are String, Integer, Long, Double, Float and Boolean

Parameters:
value - the string value
argumentClass - the requested service argument type
Returns:
ServiceArgument instance based on value and class, or null