Class ConfigHelper


  • public final class ConfigHelper
    extends Object
    Common Configuration utilities.
    • Method Detail

      • suspendablePublisher

        public static <T> Flow.Publisher<T> suspendablePublisher​(Flow.Publisher<T> delegatePublisher,
                                                                 Runnable onFirstSubscriptionRequest,
                                                                 Runnable onLastSubscriptionCancel)
        Creates a Flow.Publisher which wraps the provided one and also supports "active" and "suspended" states.

        The new Publisher starts in the "suspended" state. Upon the first subscriber request the Publisher transitions into the "active" state and invokes the caller-supplied onFirstSubscriptionRequest Runnable. When the last subscriber cancels the returned Publisher transitions into the "suspended" state and invokes the caller-provided onLastSubscriptionCancel Runnable.

        Type Parameters:
        T - the type of the items provided by the publisher
        Parameters:
        delegatePublisher - publisher to be wrapped
        onFirstSubscriptionRequest - hook invoked when the first subscriber requests events from the publisher
        onLastSubscriptionCancel - hook invoked when last remaining subscriber cancels its subscription
        Returns:
        new instance of suspendable Flow.Publisher
      • detectContentType

        public static String detectContentType​(Path path)
        Infers the content type contained in the provided Path.
        Parameters:
        path - path to check
        Returns:
        string with content type