public final class DescribableModel<T> extends Object implements Serializable
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. |
DescribableParameter |
getFirstRequiredParameter()
If this model has any required parameter, return the first one.
|
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.
|
DescribableParameter |
getSoleRequiredParameter()
If this model has one and only one required parameter, return it.
|
Class<T> |
getType()
A concrete class, usually
Describable. |
boolean |
hasSingleRequiredParameter()
Returns true if this model has one and only one required parameter.
|
T |
instantiate(Map<String,?> arguments)
Creates an instance of a class via
DataBoundConstructor and DataBoundSetter. |
String |
toString() |
static Map<String,Object> |
uninstantiate_(Object o)
Deprecated.
as of 1.2. Use
uninstantiate2_(Object) |
Map<String,Object> |
uninstantiate(T o)
Deprecated.
as of 1.2
Use
uninstantiate2(Object) |
static UninstantiatedDescribable |
uninstantiate2_(Object o)
In case if you just need to uninstantiate one object and be done with it.
|
UninstantiatedDescribable |
uninstantiate2(T o)
Disects a given instance into
UninstantiatedDescribable that you can re-instantiate
via UninstantiatedDescribable.instantiate(). |
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 boolean hasSingleRequiredParameter()
UninstantiatedDescribable.ANONYMOUS_KEY@CheckForNull public DescribableParameter getSoleRequiredParameter()
UninstantiatedDescribable.ANONYMOUS_KEY@CheckForNull public DescribableParameter getFirstRequiredParameter()
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
uninstantiate2(Object)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 UninstantiatedDescribable uninstantiate2(T o) throws UnsupportedOperationException
UninstantiatedDescribable that you can re-instantiate
via UninstantiatedDescribable.instantiate().o - a data-bound objectUnsupportedOperationException - if the class does not follow the expected structurepublic static Map<String,Object> uninstantiate_(Object o)
uninstantiate2_(Object)public static UninstantiatedDescribable uninstantiate2_(Object o)
@CheckForNull public String getHelp() throws IOException
IOExceptionDescriptor.doHelp(org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse)Copyright © 2016. All rights reserved.