public final class DescribableModel<T> extends Object
Describable with DataBoundConstructor and DataBoundSetter.
Provides such operations like
DataBoundConstructor or DataBoundSetter.
See DescribableParameter for more details
| Constructor and Description |
|---|
DescribableModel(Class<T> clazz)
Loads a definition of the structure of a class: what kind of data
you might get back from
uninstantiate(T) on an instance,
or might want to pass to instantiate(Map). |
| Modifier and Type | Method and Description |
|---|---|
String |
getDisplayName()
Corresponds to
Descriptor.getDisplayName() where available. |
String |
getHelp()
Loads help defined for this object as a whole
|
DescribableParameter |
getParameter(String name) |
Collection<DescribableParameter> |
getParameters()
A map from parameter names to types.
|
Class<T> |
getType()
A concrete class, usually
Describable. |
T |
instantiate(Map<String,?> arguments)
Creates an instance of a class via
DataBoundConstructor and DataBoundSetter. |
String |
toString() |
static Map<String,Object> |
uninstantiate_(Object o)
In case if you just need to uninstantiate one object and be done with it.
|
Map<String,Object> |
uninstantiate(T o)
Computes arguments suitable to pass to
instantiate(java.util.Map<java.lang.String, ?>) to reconstruct this object. |
public static final String CLAZZ
public DescribableModel(Class<T> clazz)
uninstantiate(T) on an instance,
or might want to pass to instantiate(Map).public Collection<DescribableParameter> getParameters()
DataBoundConstructor,
or the JavaBeans property name corresponding to a DataBoundSetter.
Sorted by the mandatory parameters first (in the order they are specified in the code), followed by optional arguments.
public DescribableParameter getParameter(String name)
public String getDisplayName()
Descriptor.getDisplayName() where available.public T instantiate(Map<String,?> arguments) throws Exception
DataBoundConstructor and DataBoundSetter.
The arguments may be primitives (as wrappers) or Strings if that is their declared type.
Characters, Enums, and URLs may be represented by Strings.
Other object types may be passed in “raw” as well, but JSON-like structures are encouraged instead.
Specifically a List may be used to represent any list- or array-valued argument.
A Map with String keys may be used to represent any class which is itself data-bound.
In that case the special key CLAZZ is used to specify the Class.getName();
or it may be omitted if the argument is declared to take a concrete type;
or Class.getSimpleName() may be used in case the argument type is Describable
and only one subtype is registered (as a Descriptor) with that simple name.
Exceptionpublic Map<String,Object> uninstantiate(T o) throws UnsupportedOperationException
instantiate(java.util.Map<java.lang.String, ?>) to reconstruct this object.o - a data-bound objectUnsupportedOperationException - if the class does not follow the expected structurepublic static Map<String,Object> uninstantiate_(Object o)
@CheckForNull public String getHelp() throws IOException
IOExceptionDescriptor.doHelp(org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse)Copyright © 2016. All rights reserved.