Package io.helidon.config
Class ConfigHelper
- java.lang.Object
-
- io.helidon.config.ConfigHelper
-
public final class ConfigHelper extends Object
Common Configuration utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ReadercreateReader(Readable readable)static StringdetectContentType(Path path)Infers the content type contained in the providedPath.static <T> Flow.Subscriber<T>subscriber(Function<T,Boolean> onNextFunction)Creates aFlow.Subscriberthat will delegateFlow.Subscriber.onNext(Object)to the specifiedonNextFunctionfunction.static <T> Flow.Publisher<T>suspendablePublisher(Flow.Publisher<T> delegatePublisher, Runnable onFirstSubscriptionRequest, Runnable onLastSubscriptionCancel)Creates aFlow.Publisherwhich wraps the provided one and also supports "active" and "suspended" states.
-
-
-
Method Detail
-
createReader
public static Reader createReader(Readable readable) throws IOException
Creates aReaderfrom the givenReadableobject.Equivalent to
createReader(readable, 1024). SeecreateReader(Readable,int).- Parameters:
readable- a readable- Returns:
- a reader
- Throws:
IOException- whenReadable.read(CharBuffer)encounters an error
-
subscriber
public static <T> Flow.Subscriber<T> subscriber(Function<T,Boolean> onNextFunction)
Creates aFlow.Subscriberthat will delegateFlow.Subscriber.onNext(Object)to the specifiedonNextFunctionfunction.The new subscriber's
Flow.Subscriber.onSubscribe(Flow.Subscription)method automatically invokesFlow.Subscription.request(long)to request all events that are available in the subscription.The caller-provided
onNextFunctionshould returnfalsein order tocancelcurrent subscription.- Type Parameters:
T- the type of the items provided by the subscription- Parameters:
onNextFunction- function to be invoked duringonNextprocessing- Returns:
Subscriberthat delegates itsonNextto the caller-provided function
-
suspendablePublisher
public static <T> Flow.Publisher<T> suspendablePublisher(Flow.Publisher<T> delegatePublisher, Runnable onFirstSubscriptionRequest, Runnable onLastSubscriptionCancel)
Creates aFlow.Publisherwhich wraps the provided one and also supports "active" and "suspended" states.The new
Publisherstarts in the "suspended" state. Upon the first subscriber request thePublishertransitions into the "active" state and invokes the caller-suppliedonFirstSubscriptionRequestRunnable. When the last subscriber cancels the returnedPublishertransitions into the "suspended" state and invokes the caller-providedonLastSubscriptionCancelRunnable.- Type Parameters:
T- the type of the items provided by the publisher- Parameters:
delegatePublisher- publisher to be wrappedonFirstSubscriptionRequest- hook invoked when the first subscriber requests events from the publisheronLastSubscriptionCancel- hook invoked when last remaining subscriber cancels its subscription- Returns:
- new instance of suspendable
Flow.Publisher
-
-