Class AbstractSource.Builder<B extends AbstractSource.Builder<B,​T,​S>,​T,​S>

  • Type Parameters:
    B - type of Builder implementation
    T - type of key source attributes (target) used to construct polling strategy from
    S - type of source that should be built
    Direct Known Subclasses:
    AbstractConfigSource.Builder, AbstractOverrideSource.Builder
    Enclosing class:
    AbstractSource<T,​S>

    public abstract static class AbstractSource.Builder<B extends AbstractSource.Builder<B,​T,​S>,​T,​S>
    extends Object
    A common AbstractSource builder, suitable for concrete Builder implementations related to AbstractSource extensions to extend.

    The application can control this behavior:

    • mandatory - whether the resource is mandatory (by default) or optional
    • pollingStrategy - which source reload policy to use
    • changes executor and subscriber's buffer size - related to propagating source changes
    • Constructor Detail

      • Builder

        protected Builder​(Class<T> targetType)
        Initializes builder.
        Parameters:
        targetType - target type
    • Method Detail

      • thisBuilder

        protected B thisBuilder()
        Returns current builder instance.
        Returns:
        builder instance
      • init

        protected B init​(Config metaConfig)
        Initialize builder from specified configuration properties.

        Supported configuration properties:

        Parameters:
        metaConfig - configuration properties used to initialize a builder instance.
        Returns:
        modified builder instance
      • pollingStrategy

        public final B pollingStrategy​(Function<T,​Supplier<PollingStrategy>> pollingStrategyProvider)
        Sets the polling strategy that accepts key source attributes.

        Concrete subclasses should override target() to provide the key source attributes (target). For example, the Builder for a FileConfigSource or ClasspathConfigSource uses the Path to the corresponding file or resource as the key source attribute (target), while the Builder for a UrlConfigSource uses the URL.

        Parameters:
        pollingStrategyProvider - a polling strategy provider
        Returns:
        a modified builder instance
        Throws:
        UnsupportedOperationException - if the concrete Builder implementation does not support the polling strategy
        See Also:
        pollingStrategy(Supplier), target()
      • target

        protected T target()
        Returns key source attributes (target).
        Returns:
        key source attributes (target).
      • optional

        public B optional()
        Built ConfigSource will not be mandatory, i.e. it is ignored if configuration target does not exists.
        Returns:
        a modified builder instance
      • build

        public abstract S build()
        Builds new instance of S.
        Returns:
        new instance of S.
      • isMandatory

        protected boolean isMandatory()
        Returns mandatory property.
        Returns:
        mandatory property.
      • pollingStrategy

        protected PollingStrategy pollingStrategy()
        Returns polling-strategy property.
        Returns:
        polling-strategy property.
      • changesExecutor

        protected Executor changesExecutor()
        Returns changes-executor property.
        Returns:
        changes-executor property.
      • changesMaxBuffer

        protected int changesMaxBuffer()
        Returns changes-max-buffer property.
        Returns:
        changes-max-buffer property.
      • retryPolicy

        protected RetryPolicy retryPolicy()
        Retry policy configured in this builder.
        Returns:
        retry policy