Generic implementation of {@link Mapper} that maps Sling {@link Resource} to a {@link SliceResource} usingreflection.
It is assumed that SliceResource field names are exactly the same as property names in the JCR node represented by the resource. Mapper iterates over fields in the SliceResource and assigns values from resource to SliceResource using mapping strategy defined by the SliceResource.
The mapper is extendable - it can process fields depending on a list of specified {@link FieldProcessor}s. The mapper uses at least one {@link FieldProcessor} which is {@link DefaultFieldProcessor}.
A field in SliceResource must be assignable from type of associated field in the repository, or an exception will be thrown during mapping. Using primitive types supported, but discouraged: if corresponding property is missing, the SliceResource should contain
null value, and a higher level logic should handle it and assign default value. Such behavior is not possible with primitive types.
Once a value of a field has been set (mapped) it can be post-processed by specified {@link FieldPostProcessor}s.
SliceResource fields can also be tagged with annotations to enable custom logic. Currently supported annotations are:
- FieldProcessors:
- {@link JcrProperty} - for mapping field to a property of different name, or defining that a fieldshould be mapped if {@link MappingStrategy#ANNOTATED} was chosen
- {@link IgnoreProperty} - those will be ignored by this Mapper if {@link MappingStrategy#ALL} was chosen
- {@link ImagePath} - indicating Image resource type which should be mapped to String field
- FieldPostProcessors:
- {@link Unescaped} - for string values that should not be HTML-escaped
See each annotation documentation for more detailed use guidelines.