The commits have the details of each change, but in general these are cleanups/refactorings with a few goals in mind
Make the code testable.
Make the code more maintainable (e.g. reducing complexity a la Sonar rules).
Fix a potential bug when creating a model without specifying what type of model you want..
Fix a potential bug when there is a resourceSuperType cycle when there
There is a chance that Sling Models will give you the wrong type of model, even if a class exists that implements the ComponentDataElement interface, unless you explicitly ask for a model of that type. This was done by using createModel instead of getModelFrom*. The former allows you to specify a type to use, and takes advantage of the ResourceTypeBasedResourcePicker, which is set to a higher precedence than the default FirstImplementationPicker. This problem would be exacerbated by Sling Models Exporters, where you would have two models (the exporter model, and the data layer model) both specifying the resource type.
Another benefit of using createModel is type-safety: it is a generic method that returns an instance of your type, eliminating the explicit check & cast.
The commits have the details of each change, but in general these are cleanups/refactorings with a few goals in mind
resourceSuperType
cycle when thereThere is a chance that Sling Models will give you the wrong type of model, even if a class exists that implements the
ComponentDataElement
interface, unless you explicitly ask for a model of that type. This was done by usingcreateModel
instead ofgetModelFrom*
. The former allows you to specify a type to use, and takes advantage of theResourceTypeBasedResourcePicker
, which is set to a higher precedence than the defaultFirstImplementationPicker
. This problem would be exacerbated by Sling Models Exporters, where you would have two models (the exporter model, and the data layer model) both specifying the resource type.Another benefit of using
createModel
is type-safety: it is a generic method that returns an instance of your type, eliminating the explicit check & cast.