Class MappersConfig.BuilderBase<BUILDER extends MappersConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends MappersConfig>

java.lang.Object
io.helidon.common.mapper.MappersConfig.BuilderBase<BUILDER,PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER,PROTOTYPE>
Direct Known Subclasses:
MappersConfig.Builder
Enclosing interface:
MappersConfig

public abstract static class MappersConfig.BuilderBase<BUILDER extends MappersConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends MappersConfig> extends Object implements Prototype.Builder<BUILDER,PROTOTYPE>
Fluent API builder base for Mappers.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(MappersConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(MappersConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • addMapper

      public <S, T> BUILDER addMapper(Mapper<S,T> mapper, Class<S> sourceType, Class<T> targetType, String... qualifiers)
      Add a mapper to the list of mapper.
      Type Parameters:
      S - type of source
      T - type of target
      Parameters:
      mapper - the mapper to map source instances to target instances
      sourceType - class of the source instance
      targetType - class of the target instance
      qualifiers - supported qualifiers of this mapper (if none provided, will return a compatible response)
      Returns:
      updated builder instance
    • addMapper

      public <S, T> BUILDER addMapper(Mapper<S,T> mapper, GenericType<S> sourceType, GenericType<T> targetType, String... qualifiers)
      Add a mapper to the list of mapper.
      Type Parameters:
      S - type of source
      T - type of target
      Parameters:
      mapper - the mapper to map source instances to target instances
      sourceType - generic type of the source instance
      targetType - generic type of the target instance
      qualifiers - qualifiers of this mapper, if empty, will be a compatible mapper
      Returns:
      updated builder instance
    • addMapper

      public <S, T> BUILDER addMapper(Mapper<S,T> mapper, Class<S> sourceType, Class<T> targetType, double weight, String... qualifiers)
      Add a mapper to the list of mapper with a custom priority.
      Type Parameters:
      S - type of source
      T - type of target
      Parameters:
      mapper - the mapper to map source instances to target instances
      sourceType - class of the source instance
      targetType - class of the target instance
      weight - weight of the mapper
      qualifiers - supported qualifiers of this mapper (if none provided, will return a compatible response)
      Returns:
      updated builder instance
    • addMapper

      public <S, T> BUILDER addMapper(Mapper<S,T> mapper, GenericType<S> sourceType, GenericType<T> targetType, double weight, String... qualifiers)
      Add a mapper to the list of mapper with custom priority.
      Type Parameters:
      S - type of source
      T - type of target
      Parameters:
      mapper - the mapper to map source instances to target instances
      sourceType - generic type of the source instance
      targetType - generic type of the target instance
      weight - weight of the mapper
      qualifiers - qualifiers of this mapper, if empty, will be a compatible mapper
      Returns:
      updated builder instance
    • serviceRegistry

      public BUILDER serviceRegistry(ServiceRegistry registry)
      Provide an explicit registry instance to use.

      If not configured, the GlobalServiceRegistry would be used to discover services.

      Parameters:
      registry - service registry instance
      Returns:
      updated builder instance
    • mapperProvidersDiscoverServices

      public BUILDER mapperProvidersDiscoverServices(boolean discoverServices)
      Mapper providers allow for introduction of new mappers into the system. A mapper provider can be exposed either as a ServiceRegistry service, or a ServiceLoader, but never both.

      Mapper providers are ordered by their Weight.

      Parameters:
      discoverServices - whether to discover implementations through service loader
      Returns:
      updated builder instance
      See Also:
    • mapperProviders

      public BUILDER mapperProviders(List<? extends MapperProvider> mapperProviders)
      Mapper providers allow for introduction of new mappers into the system. A mapper provider can be exposed either as a ServiceRegistry service, or a ServiceLoader, but never both.

      Mapper providers are ordered by their Weight.

      Parameters:
      mapperProviders - a list of configured mapper providers
      Returns:
      updated builder instance
      See Also:
    • addMapperProviders

      public BUILDER addMapperProviders(List<? extends MapperProvider> mapperProviders)
      Mapper providers allow for introduction of new mappers into the system. A mapper provider can be exposed either as a ServiceRegistry service, or a ServiceLoader, but never both.

      Mapper providers are ordered by their Weight.

      Parameters:
      mapperProviders - a list of configured mapper providers
      Returns:
      updated builder instance
      See Also:
    • addMapperProvider

      public BUILDER addMapperProvider(MapperProvider mapperProvider)
      Mapper providers allow for introduction of new mappers into the system. A mapper provider can be exposed either as a ServiceRegistry service, or a ServiceLoader, but never both.

      Mapper providers are ordered by their Weight.

      Parameters:
      mapperProvider - a list of configured mapper providers
      Returns:
      updated builder instance
      See Also:
    • mappersDiscoverServices

      public BUILDER mappersDiscoverServices(boolean discoverServices)
      Mappers discovered through ServiceRegistry, or explicitly created that implement both Mapper.sourceType() and Mapper.targetType() methods.

      Mappers are ordered by Weight together with MappersConfigBlueprint.mapperProviders() to create a single list.

      Parameters:
      discoverServices - whether to discover implementations through service loader
      Returns:
      updated builder instance
      See Also:
    • mappers

      public BUILDER mappers(List<Mapper<?,?>> mappers)
      Mappers discovered through ServiceRegistry, or explicitly created that implement both Mapper.sourceType() and Mapper.targetType() methods.

      Mappers are ordered by Weight together with MappersConfigBlueprint.mapperProviders() to create a single list.

      Parameters:
      mappers - list of mappers
      Returns:
      updated builder instance
      See Also:
    • addMappers

      public BUILDER addMappers(List<Mapper<?,?>> mappers)
      Mappers discovered through ServiceRegistry, or explicitly created that implement both Mapper.sourceType() and Mapper.targetType() methods.

      Mappers are ordered by Weight together with MappersConfigBlueprint.mapperProviders() to create a single list.

      Parameters:
      mappers - list of mappers
      Returns:
      updated builder instance
      See Also:
    • addMapper

      public BUILDER addMapper(Mapper<?,?> mapper)
      Mappers discovered through ServiceRegistry, or explicitly created that implement both Mapper.sourceType() and Mapper.targetType() methods.

      Mappers are ordered by Weight together with MappersConfigBlueprint.mapperProviders() to create a single list.

      Parameters:
      mapper - list of mappers
      Returns:
      updated builder instance
      See Also:
    • useBuiltInMappers

      public BUILDER useBuiltInMappers(boolean useBuiltInMappers)
      Whether to use built-in mappers. Defaults to true.
      Parameters:
      useBuiltInMappers - whether to use built in mappers (such as String to Integer)
      Returns:
      updated builder instance
      See Also:
    • mapperProviders

      public List<MapperProvider> mapperProviders()
      Mapper providers allow for introduction of new mappers into the system. A mapper provider can be exposed either as a ServiceRegistry service, or a ServiceLoader, but never both.

      Mapper providers are ordered by their Weight.

      Returns:
      the mapper providers
    • mappers

      public List<Mapper<?,?>> mappers()
      Mappers discovered through ServiceRegistry, or explicitly created that implement both Mapper.sourceType() and Mapper.targetType() methods.

      Mappers are ordered by Weight together with MappersConfigBlueprint.mapperProviders() to create a single list.

      Returns:
      the mappers
    • useBuiltInMappers

      public boolean useBuiltInMappers()
      Whether to use built-in mappers. Defaults to true.
      Returns:
      the use built in mappers
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.