@ProviderType
public interface ModelFactory
Modifier and Type | Method and Description |
---|---|
boolean |
canCreateFromAdaptable(Object adaptable,
Class<?> type) |
<ModelType> |
createModel(Object adaptable,
Class<ModelType> type)
Instantiates the given Sling Model class from the given adaptable.
|
boolean |
isModelClass(Class<?> type)
Checks if a given type can be instantiated though Sling Models.
|
boolean |
isModelClass(Object adaptable,
Class<?> type)
Deprecated.
Use
isModelClass(Class) instead! |
@Nonnull <ModelType> ModelType createModel(@Nonnull Object adaptable, @Nonnull 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 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 Object adaptable, @Nonnull Class<?> type) throws ModelClassException
adaptable
- the adaptable to checktype
- the class to checktrue
in case the given class can be created from the given adaptableModelClassException
- in case no class with the Model annotation adapts to the requested type@Deprecated boolean isModelClass(@Nonnull Object adaptable, @Nonnull Class<?> type)
isModelClass(Class)
instead!adaptable
- the adaptable to checktype
- the class to checkModel
boolean isModelClass(@Nonnull 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.Copyright © 2015 The Apache Software Foundation. All rights reserved.