Class DescribableModel<T>
- All Implemented Interfaces:
Serializable
Describable with DataBoundConstructor and DataBoundSetter.
Provides such operations like
- instantiate this class from a JSON-like map
- take an existing instance and produces a JSON-like map that can be then fed back to the above instantiation call
-
enumerate parameters of this Describable that are defined
either through
DataBoundConstructororDataBoundSetter. SeeDescribableParameterfor more details - access help file
- Author:
- Jesse Glick, Andrew Bayer, Kohsuke Kawaguchi
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDescribableModel(Class<T> clazz) Loads a definition of the structure of a class: what kind of data you might get back fromuninstantiate(T)on an instance, or might want to pass toinstantiate(Map). -
Method Summary
Modifier and TypeMethodDescriptionCorresponds toDescriptor.getDisplayName()where available.If this model has any required parameter, return the first one.getHelp()Loads help defined for this object as a wholegetParameter(String name) A map from parameter names to types.If this model has one and only one required parameter, return it.getType()A concrete class, usuallyDescribable.booleanReturns true if this model has one and only one required parameter.instantiate(Map<String, ?> arguments) Deprecated.instantiate(Map<String, ?> arguments, TaskListener listener) Creates an instance of a class viaDataBoundConstructorandDataBoundSetter.booleanTrue if this model's type is deprecated.static <T> DescribableModel<T> Binds type parameter, preferred means of obtaining a DescribableModel.toString()uninstantiate(T o) Deprecated.as of 1.2 Useuninstantiate2(Object)Deprecated.as of 1.2.uninstantiate2(T o) Disects a given instance intoUninstantiatedDescribablethat you can re-instantiate viaUninstantiatedDescribable.instantiate().static UninstantiatedDescribableIn case if you just need to uninstantiate one object and be done with it.
-
Field Details
-
STRICT_PARAMETER_CHECKING
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean STRICT_PARAMETER_CHECKING -
CLAZZ
- See Also:
-
-
Constructor Details
-
DescribableModel
Loads a definition of the structure of a class: what kind of data you might get back fromuninstantiate(T)on an instance, or might want to pass toinstantiate(Map). Useof(Class)instead -- that will returned cached instances.
-
-
Method Details
-
of
Binds type parameter, preferred means of obtaining a DescribableModel. -
getType
A concrete class, usuallyDescribable. -
getParameters
A map from parameter names to types. A parameter name is either the name of an argument to aDataBoundConstructor, or the JavaBeans property name corresponding to aDataBoundSetter.Sorted by the mandatory parameters first (in the order they are specified in the code), followed by optional arguments.
-
getParameter
-
hasSingleRequiredParameter
public boolean hasSingleRequiredParameter()Returns true if this model has one and only one required parameter.- See Also:
-
getSoleRequiredParameter
If this model has one and only one required parameter, return it. Otherwise null.- See Also:
-
getFirstRequiredParameter
If this model has any required parameter, return the first one. Otherwise null. -
getDisplayName
Corresponds toDescriptor.getDisplayName()where available. -
instantiate
Deprecated.instead useinstantiate(Map, TaskListener)- Throws:
IllegalArgumentException
-
instantiate
public T instantiate(Map<String, ?> arguments, @CheckForNull TaskListener listener) throws IllegalArgumentExceptionCreates an instance of a class viaDataBoundConstructorandDataBoundSetter.The arguments may be primitives (as wrappers) or
Strings if that is their declared type.Characters,Enums, andURLs may be represented byStrings. Other object types may be passed in “raw” as well, but JSON-like structures are encouraged instead. Specifically aListmay be used to represent any list- or array-valued argument. AMapwithStringkeys may be used to represent any class which is itself data-bound. In that case the special keyCLAZZis used to specify theClass.getName(); or it may be omitted if the argument is declared to take a concrete type; orClass.getSimpleName()may be used in case the argument type isDescribableand only one subtype is registered (as aDescriptor) with that simple name.- Parameters:
arguments- The arguments used to create the instancelistener- Listener to record any instantiation warnings- Returns:
- The instantiated object
- Throws:
IllegalArgumentException
-
uninstantiate
Deprecated.as of 1.2 Useuninstantiate2(Object)Computes arguments suitable to pass toinstantiate(java.util.Map<java.lang.String, ?>)to reconstruct this object.- Parameters:
o- a data-bound object- Returns:
- constructor and/or setter parameters
- Throws:
UnsupportedOperationException- if the class does not follow the expected structure
-
uninstantiate2
Disects a given instance intoUninstantiatedDescribablethat you can re-instantiate viaUninstantiatedDescribable.instantiate().- Parameters:
o- a data-bound object- Returns:
- constructor and/or setter parameters
- Throws:
UnsupportedOperationException- if the class does not follow the expected structure
-
uninstantiate_
Deprecated.as of 1.2. Useuninstantiate2_(Object)In case if you just need to uninstantiate one object and be done with it. -
uninstantiate2_
In case if you just need to uninstantiate one object and be done with it. -
isDeprecated
public boolean isDeprecated()True if this model's type is deprecated. A model is deprecated if it'stypeis marked asDeprecated. -
getHelp
Loads help defined for this object as a whole- Returns:
- some HTML (in English locale), if available, else null
- Throws:
IOException- See Also:
-
toString
-
instantiate(Map, TaskListener)