Package chemaxon.marvin.services
Class ServiceArgument<T>
- java.lang.Object
-
- chemaxon.marvin.services.ServiceArgument<T>
-
- Type Parameters:
T
- the type of the argument
- Direct Known Subclasses:
DynamicArgument
@PublicAPI public class ServiceArgument<T> extends Object
Describes an argument passed to services- Since:
- 5.6
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ServiceArgument(Class<T> type, T value)
Constructs a service argument with specified type and valueprotected
ServiceArgument(Class<T> type, T value, boolean constant)
Constructs a service argument with specified type and value
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> ServiceArgument<T>
createArgument(String name, T value)
Returns a service argument based on valuestatic <T> ServiceArgument<T>
createArgument(T value)
Returns a service argument based on valuestatic <T> ServiceArgument<T>
createArgumentAs(String name, T value, Class<T> type)
Returns a service argument based on value and typestatic <T> ServiceArgument<T>
createArgumentAs(T value, Class<T> type)
Returns a service argument based on value and typestatic ServiceArgument<?>
createConstantFromString(String value, Class<?> argumentClass)
String
getAlias()
Returns the argument alias.String
getName()
Returns the name of the argumentClass<T>
getType()
Returns the argument typeT
getValue()
Returns the argument valueboolean
isValid()
Returnstrue
if service argument is validvoid
setAlias(String alias)
Sets the argument alias.void
setName(String name)
Sets the name of the argumentvoid
setType(Class<T> argumentType)
Sets the class of the argumentvoid
setValue(T value)
Sets the service argument valueString
toString()
-
-
-
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(String name, T value)
Returns a service argument based on value- Type Parameters:
T
- the argument type- Parameters:
name
- argument namevalue
- the argument value- Returns:
- a constant service argument based on value
-
createArgumentAs
public static <T> ServiceArgument<T> createArgumentAs(T value, Class<T> type)
Returns a service argument based on value and type- Type Parameters:
T
- the argument type- Parameters:
value
- the argument valuetype
- the argument type- Returns:
- a constant service argument based on value
-
createArgumentAs
public static <T> ServiceArgument<T> createArgumentAs(String name, T value, Class<T> type)
Returns a service argument based on value and type- Type Parameters:
T
- the argument type- Parameters:
name
- the argument namevalue
- the argument valuetype
- the argument type- Returns:
- a constant service argument based on value
-
setType
public void setType(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()
Returnstrue
if service argument is valid- Returns:
true
if service argument is valid
-
getName
public String getName()
Returns the name of the argument- Returns:
- the name of the argument
-
setName
public void setName(String name)
Sets the name of the argument- Parameters:
name
- the new argument name
-
getAlias
public 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(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
-
createConstantFromString
public static ServiceArgument<?> createConstantFromString(String value, Class<?> argumentClass)
Creates aServiceArgument
constant based on string value and argument type.
Supported types areString
,Integer
,Long
,Double
,Float
andBoolean
- Parameters:
value
- the string valueargumentClass
- the requested service argument type- Returns:
ServiceArgument
instance based on value and class, ornull
-
-