Package org.apache.sling.caconfig
Interface ConfigurationBuilder
@ProviderType
public interface ConfigurationBuilder
Defines how the configuration should be mapped and returned.
-
Method Summary
Modifier and TypeMethodDescription<T> TGet configuration as singleton resource and its properties mapped to the given annotation class.<T> TasAdaptable(@NotNull Class<T> clazz) Get configuration as singleton configuration resource and adapt it to the given class.<T> @NotNull Collection<T>asAdaptableCollection(@NotNull Class<T> clazz) Get collection of configuration resources and adapt them to the given class.<T> @NotNull Collection<T>asCollection(@NotNull Class<T> clazz) Get collection of configuration resources with their properties mapped to the given annotation class.@NotNull ValueMapGet configuration as singleton resource and return its properties as value map.@NotNull Collection<ValueMap>Get collection of configuration resources with their properties mapped to the given annotation class.<T> booleanThis method checks for the configuration existence based onconfigNamedefined in the configuration definition.booleanThis method checks for the configuration existence based on providedconfigNamevalue.@NotNull ConfigurationBuilderDefine configuration name.
-
Method Details
-
name
Define configuration name. Optional for theas(Class),asCollection(Class)andhas(Class)methods, mandatory for the others.- Parameters:
configName- Relative path- Returns:
- Configuration builder
-
as
Get configuration as singleton resource and its properties mapped to the given annotation class. Configuration name is optional - if not given vianame(String)method it is derived from the annotation interface class name.- Type Parameters:
T- Annotation class type- Parameters:
clazz- Annotation interface class- Returns:
- Configuration object. Contains only the default values if content resource or configuration cannot be found.
-
asCollection
Get collection of configuration resources with their properties mapped to the given annotation class. Configuration name is optional - if not given vianame(String)method it is derived from the annotation interface class name.- Type Parameters:
T- Annotation class type- Parameters:
clazz- Annotation interface class- Returns:
- Collection of configuration objects. Is empty if content resource or configuration cannot be found.
-
asValueMap
Get configuration as singleton resource and return its properties as value map.- Returns:
- Value map. If content resource or configuration cannot be found the map is empty unless default or configuration override values are present for this configuration.
-
asValueMapCollection
Get collection of configuration resources with their properties mapped to the given annotation class.- Returns:
- Collection of value maps. Is empty if content resource or configuration cannot be found.
-
asAdaptable
Get configuration as singleton configuration resource and adapt it to the given class.- Type Parameters:
T- Annotation class type- Parameters:
clazz- Class that can be adapted from aResource- Returns:
- Object instance or null if content resource or configuration cannot be found or if the adaption was not possible.
-
asAdaptableCollection
Get collection of configuration resources and adapt them to the given class.- Type Parameters:
T- Annotation class type- Parameters:
clazz- Class that can be adapted from aResource- Returns:
- Collection of object instances. Is empty if content resource or configuration cannot be found or if the adaption was not possible.
-
has
This method checks for the configuration existence based onconfigNamedefined in the configuration definition. It extracts theconfigNamefrom the given annotation class and checks if the configuration is available for the context path in the current resource hierarchy. If not found, also checks in the global fall-back paths configured viaorg.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategywhich by default are/conf/global,/apps/configand/libs/config.This method does not consider the default values provided in the configuration definition.- Type Parameters:
T- Annotation class type- Parameters:
clazz- Class that can be adapted from aResource- Returns:
- True/False based on configuration resource node existence.
-
has
This method checks for the configuration existence based on providedconfigNamevalue. It checks if the configuration is available for the context path in the current resource hierarchy and if not found, also checks in the global fall-back paths configured viaorg.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategywhich by default are/conf/global,/apps/configand/libs/config. This method does not consider the default values provided in the configuration definition.- Parameters:
configName- Name of the configuration- Returns:
- True/False based on configuration resource node existence.
-