@ProviderType
public interface ModelFactory
Modifier and Type | Method and Description |
---|---|
boolean |
canCreateFromAdaptable(java.lang.Object adaptable,
java.lang.Class<?> type) |
<ModelType> |
createModel(java.lang.Object adaptable,
java.lang.Class<ModelType> type)
Instantiates the given Sling Model class from the given adaptable.
|
<T> T |
exportModel(java.lang.Object model,
java.lang.String exporterName,
java.lang.Class<T> targetClass,
java.util.Map<java.lang.String,java.lang.String> options)
Export the model object using the defined target class using the named exporter.
|
<T> T |
exportModelForRequest(SlingHttpServletRequest request,
java.lang.String exporterName,
java.lang.Class<T> targetClass,
java.util.Map<java.lang.String,java.lang.String> options)
Export the model object registered to the request's resource's type using the defined target class using the named exporter.
|
<T> T |
exportModelForResource(Resource resource,
java.lang.String exporterName,
java.lang.Class<T> targetClass,
java.util.Map<java.lang.String,java.lang.String> options)
Export the model object registered to the resource's type using the defined target class using the named exporter.
|
java.lang.Object |
getModelFromRequest(SlingHttpServletRequest request)
Obtain an adapted model class based on the resource type of the request's resource.
|
java.lang.Object |
getModelFromResource(Resource resource)
Obtain an adapted model class based on the resource type of the provided resource.
|
<T> T |
getModelFromWrappedRequest(SlingHttpServletRequest request,
Resource resource,
java.lang.Class<T> targetClass)
Create a wrapped request object with the specified resource and (try to) adapt the request object into the specified class.
|
boolean |
isModelAvailableForRequest(SlingHttpServletRequest request)
Determine is a model class is available for the request's resource's resource type.
|
boolean |
isModelAvailableForResource(Resource resource)
Determine is a model class is available for the resource's resource type.
|
boolean |
isModelClass(java.lang.Class<?> type)
Checks if a given type can be instantiated though Sling Models.
|
boolean |
isModelClass(java.lang.Object adaptable,
java.lang.Class<?> type)
Deprecated.
Use
isModelClass(Class) instead! |
@Nonnull <ModelType> ModelType createModel(@Nonnull java.lang.Object adaptable, @Nonnull java.lang.Class<ModelType> type) throws MissingElementsException, InvalidAdaptableException, ModelClassException, PostConstructException, ValidationException, InvalidModelException
adaptable
- the adaptable to use to instantiate the Sling Model Classtype
- the class to instantiatenull
)MissingElementsException
- in case no injector was able to inject some required values with the given typesInvalidAdaptableException
- in case the given class cannot be instantiated from the given adaptable (different adaptable on the model annotation)ModelClassException
- in case the model could not be instantiated because model annotation was missing, reflection failed, no valid constructor was found, model was not registered as adapter factory yet, or post-construct could not be calledPostConstructException
- in case the post-construct method has thrown an exception itselfValidationException
- in case validation could not be performed for some reason (e.g. no validation information available)InvalidModelException
- in case the given model type could not be validated through the model validationboolean canCreateFromAdaptable(@Nonnull java.lang.Object adaptable, @Nonnull java.lang.Class<?> type)
adaptable
- the adaptable to checktype
- the class to checktrue
in case the given class can be created from the given adaptable, otherwise false
@Deprecated boolean isModelClass(@Nonnull java.lang.Object adaptable, @Nonnull java.lang.Class<?> type)
isModelClass(Class)
instead!adaptable
- the adaptable to checktype
- the class to checkModel
boolean isModelClass(@Nonnull java.lang.Class<?> type)
Model
which adapts to the given typetrue
.type
- the class to checktrue
in case the given type can be instantiated though Sling Models.boolean isModelAvailableForResource(@Nonnull Resource resource)
resource
- a resourcetrue
if a model class is mapped to the resource typeboolean isModelAvailableForRequest(@Nonnull SlingHttpServletRequest request)
request
- a requesttrue
if a model class is mapped to the resource typejava.lang.Object getModelFromResource(@Nonnull Resource resource) throws MissingElementsException, InvalidAdaptableException, ModelClassException, PostConstructException, ValidationException, InvalidModelException
resource
- a resourceMissingElementsException
- in case no injector was able to inject some required values with the given typesInvalidAdaptableException
- in case the given class cannot be instantiated from the given adaptable (different adaptable on the model annotation)ModelClassException
- in case the model could not be instantiated because model annotation was missing, reflection failed, no valid constructor was found, model was not registered as adapter factory yet, or post-construct could not be calledPostConstructException
- in case the post-construct method has thrown an exception itselfValidationException
- in case validation could not be performed for some reason (e.g. no validation information available)InvalidModelException
- in case the given model type could not be validated through the model validationjava.lang.Object getModelFromRequest(@Nonnull SlingHttpServletRequest request) throws MissingElementsException, InvalidAdaptableException, ModelClassException, PostConstructException, ValidationException, InvalidModelException
request
- a requestMissingElementsException
- in case no injector was able to inject some required values with the given typesInvalidAdaptableException
- in case the given class cannot be instantiated from the given adaptable (different adaptable on the model annotation)ModelClassException
- in case the model could not be instantiated because model annotation was missing, reflection failed, no valid constructor was found, model was not registered as adapter factory yet, or post-construct could not be calledPostConstructException
- in case the post-construct method has thrown an exception itselfValidationException
- in case validation could not be performed for some reason (e.g. no validation information available)InvalidModelException
- in case the given model type could not be validated through the model validation<T> T exportModel(java.lang.Object model, java.lang.String exporterName, java.lang.Class<T> targetClass, java.util.Map<java.lang.String,java.lang.String> options) throws ExportException, MissingExporterException
T
- the target classmodel
- the model objectexporterName
- the exporter nametargetClass
- the target classoptions
- any exporter optionsExportException
- if the export failsMissingExporterException
- if the named exporter can't be found<T> T exportModelForResource(Resource resource, java.lang.String exporterName, java.lang.Class<T> targetClass, java.util.Map<java.lang.String,java.lang.String> options) throws MissingElementsException, InvalidAdaptableException, ModelClassException, PostConstructException, ValidationException, InvalidModelException, ExportException, MissingExporterException
T
- the target classresource
- the resourceexporterName
- the exporter nametargetClass
- the target classoptions
- any exporter optionsMissingElementsException
- in case no injector was able to inject some required values with the given typesInvalidAdaptableException
- in case the given class cannot be instantiated from the given adaptable (different adaptable on the model annotation)ModelClassException
- in case the model could not be instantiated because model annotation was missing, reflection failed, no valid constructor was found, model was not registered as adapter factory yet, or post-construct could not be calledPostConstructException
- in case the post-construct method has thrown an exception itselfValidationException
- in case validation could not be performed for some reason (e.g. no validation information available)InvalidModelException
- in case the given model type could not be validated through the model validationExportException
- if the export failsMissingExporterException
- if the named exporter can't be found<T> T exportModelForRequest(SlingHttpServletRequest request, java.lang.String exporterName, java.lang.Class<T> targetClass, java.util.Map<java.lang.String,java.lang.String> options) throws MissingElementsException, InvalidAdaptableException, ModelClassException, PostConstructException, ValidationException, InvalidModelException, ExportException, MissingExporterException
T
- the target classrequest
- the requestexporterName
- the exporter nametargetClass
- the target classoptions
- any exporter optionsMissingElementsException
- in case no injector was able to inject some required values with the given typesInvalidAdaptableException
- in case the given class cannot be instantiated from the given adaptable (different adaptable on the model annotation)ModelClassException
- in case the model could not be instantiated because model annotation was missing, reflection failed, no valid constructor was found, model was not registered as adapter factory yet, or post-construct could not be calledPostConstructException
- in case the post-construct method has thrown an exception itselfValidationException
- in case validation could not be performed for some reason (e.g. no validation information available)InvalidModelException
- in case the given model type could not be validated through the model validationExportException
- if the export failsMissingExporterException
- if the named exporter can't be found<T> T getModelFromWrappedRequest(@Nonnull SlingHttpServletRequest request, @Nonnull Resource resource, @Nonnull java.lang.Class<T> targetClass)
T
- the target adapter classrequest
- the current requestresource
- the resource to set as the wrapped request's resourcetargetClass
- the target adapter classCopyright © 2018 The Apache Software Foundation. All rights reserved.