Class UninstantiatedDescribable
- java.lang.Object
-
- org.jenkinsci.plugins.structs.describable.UninstantiatedDescribable
-
- All Implemented Interfaces:
Serializable
public class UninstantiatedDescribable extends Object implements Serializable
A reflection-like view of a particularDescribableinstance.- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringANONYMOUS_KEYAs a short-hand, if aDescribableModelhas only one required parameter,instantiate(Class)accepts a single-item map whose key is this magic token.
-
Constructor Summary
Constructors Constructor Description UninstantiatedDescribable(String symbol, String klass, Map<String,?> arguments)UninstantiatedDescribable(Map<String,?> arguments)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object o)static UninstantiatedDescribablefrom(Object o)Map<String,?>getArguments()All the nested arguments to this object.StringgetKlass()"$class" is an alternative means to specify the class in case there's no symbol.DescribableModelgetModel()Returns the model associated with this object.StringgetSymbol()If this nested describable has a suitable symbol name, this method returns one.inthashCode()booleanhasSoleRequiredArgument()Returns true if and only if the arguments is one and that is the only required parameter from the model.Objectinstantiate()Deprecated.instead useinstantiate(TaskListener)Objectinstantiate(TaskListener listener)Instantiates an actualDescribablethrough the model, unlessklassorsymbolwill be set to specify a specific type, in which case that takes a precedence.<T> Tinstantiate(Class<T> base)Deprecated.instead useinstantiate(Class, TaskListener)<T> Tinstantiate(Class<T> base, TaskListener listener)Instantiates an actualDescribableobject from the specified arguments.voidsetKlass(String klass)voidsetModel(DescribableModel model)voidsetSymbol(String symbol)Map<String,Object>toMap()For legacy use, we need to blow up this into a map form.Map<String,Object>toShallowMap()Converts thisUninstantiatedDescribableto a literal map expression without recursively doing so for children.StringtoString()Debug assistance.UninstantiatedDescribablewithArguments(Map<String,?> arguments)Makes a copy of this struct with an alternate argument map.
-
-
-
Field Detail
-
ANONYMOUS_KEY
public static final String ANONYMOUS_KEY
As a short-hand, if aDescribableModelhas only one required parameter,instantiate(Class)accepts a single-item map whose key is this magic token.To avoid clients from needing to special-case this key,
from(Object)does not produceargumentsthat contains this magic token. Clients who want to take advantages of this should look atDescribableModel.hasSingleRequiredParameter()- See Also:
- Constant Field Values
-
-
Method Detail
-
withArguments
public UninstantiatedDescribable withArguments(Map<String,?> arguments)
Makes a copy of this struct with an alternate argument map.- Parameters:
arguments- a replacement forgetArguments()- Returns:
- a new object with the same
getSymbol(),getKlass(), andgetModel()
-
getSymbol
@Nullable public String getSymbol()
If this nested describable has a suitable symbol name, this method returns one.Either this or
getKlass()has to return a non-null value.
-
setSymbol
public void setSymbol(String symbol)
-
getKlass
@Nullable public String getKlass()
"$class" is an alternative means to specify the class in case there's no symbol. Can be a short name if it's contextually unambiguous, or a FQCN.Either this or
getSymbol()has to return a non-null value.
-
setKlass
public void setKlass(String klass)
-
getModel
@CheckForNull public DescribableModel getModel()
Returns the model associated with this object. If this object was created from a model (viafrom(Object)) this method returns that model.
-
setModel
public void setModel(DescribableModel model)
-
hasSoleRequiredArgument
public boolean hasSoleRequiredArgument()
Returns true if and only if the arguments is one and that is the only required parameter from the model.This usually signals a short-hand syntax to write down the instantiation syntax.
-
toMap
public Map<String,Object> toMap()
For legacy use, we need to blow up this into a map form. This requires recursively blowing up any nestedUninstantiatedDescribables.
-
toShallowMap
public Map<String,Object> toShallowMap()
Converts thisUninstantiatedDescribableto a literal map expression without recursively doing so for children.
-
instantiate
@Deprecated public Object instantiate() throws Exception
Deprecated.instead useinstantiate(TaskListener)- Throws:
Exception
-
instantiate
public Object instantiate(TaskListener listener) throws Exception
Instantiates an actualDescribablethrough the model, unlessklassorsymbolwill be set to specify a specific type, in which case that takes a precedence.- Parameters:
listener- Listener to record any instantiation warnings- Returns:
- The instantiated object
- Throws:
Exception
-
instantiate
@Deprecated public <T> T instantiate(Class<T> base) throws Exception
Deprecated.instead useinstantiate(Class, TaskListener)- Throws:
Exception
-
instantiate
public <T> T instantiate(Class<T> base, TaskListener listener) throws Exception
Instantiates an actualDescribableobject from the specified arguments.- Parameters:
base- The expected type of the instance. The interpretation of the symbol and $class depends on this parameter.listener- Listener to record any instantiation warnings- Returns:
- The instantiated object
- Throws:
Exception
-
from
public static UninstantiatedDescribable from(Object o)
-
-