Package org.apache.sling.caconfig

## Interface ConfigurationBuilder

    @ProviderType
    public interface ConfigurationBuilder

Defines how the configuration should be mapped and returned.

### Method Summary

All Methods Instance Methods Abstract Methods
`<T> T` `as​(@NotNull Class<T> clazz)` Get configuration as singleton resource and its properties mapped to the given annotation class.
`<T> T` `asAdaptable​(@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 org.apache.sling.api.resource.ValueMap` `asValueMap()` Get configuration as singleton resource and return its properties as value map.
`@NotNull Collection<org.apache.sling.api.resource.ValueMap>` `asValueMapCollection()` Get collection of configuration resources with their properties mapped to the given annotation class.
`<T> boolean` `has​(@NotNull Class<T> clazz)` This method checks for the configuration existence based on `configName` defined in the configuration definition.
`boolean` `has​(@NotNull String configName)` This method checks for the configuration existence based on provided `configName` value.
`@NotNull ConfigurationBuilder` `name​(@NotNull String configName)` Define configuration name.

### Method Detail

#### name

    @NotNull
    @NotNull ConfigurationBuilder name​(@NotNull
                                       @NotNull String configName)

Define configuration name. Optional for the `as(Class)`, `asCollection(Class)` and `has(Class)` methods, mandatory for the others.

Parameters:
  `configName` - Relative path
Returns:
  Configuration builder

#### as

    @NotNull
    <T> T as​(@NotNull
             @NotNull Class<T> clazz)

Get configuration as singleton resource and its properties mapped to the given annotation class. Configuration name is optional - if not given via `name(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

    @NotNull
    <T> @NotNull Collection<T> asCollection​(@NotNull
                                            @NotNull Class<T> clazz)

Get collection of configuration resources with their properties mapped to the given annotation class. Configuration name is optional - if not given via `name(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

    @NotNull
    @NotNull org.apache.sling.api.resource.ValueMap 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

    @NotNull
    @NotNull Collection<org.apache.sling.api.resource.ValueMap> 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

    <T> T asAdaptable​(@NotNull
                      @NotNull Class<T> clazz)

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 a `Resource`
Returns:
  Object instance or null if content resource or configuration cannot be found or if the adaption was not possible.

#### asAdaptableCollection

    @NotNull
    <T> @NotNull Collection<T> asAdaptableCollection​(@NotNull
                                                     @NotNull Class<T> clazz)

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 a `Resource`
Returns:
  Collection of object instances. Is empty if content resource or configuration cannot be found or if the adaption was not possible.

#### has

    <T> boolean has​(@NotNull
                    @NotNull Class<T> clazz)

This method checks for the configuration existence based on `configName` defined in the configuration definition. It extracts the `configName` from 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 via `org.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategy` which by default are `/conf/global`, `/apps/config` and `/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 a `Resource`
Returns:
  True/False based on configuration resource node existence.

#### has

    boolean has​(@NotNull
                @NotNull String configName)

This method checks for the configuration existence based on provided `configName` value. 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 via `org.apache.sling.caconfig.resource.impl.def.DefaultConfigurationResourceResolvingStrategy` which by default are `/conf/global`, `/apps/config` and `/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.