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 Reader
createReader(Readable readable)
static String
detectContentType(Path path)
Infers the content type contained in the providedPath
.static <T> Flow.Subscriber<T>
subscriber(Function<T,Boolean> onNextFunction)
Creates aFlow.Subscriber
that will delegateFlow.Subscriber.onNext(Object)
to the specifiedonNextFunction
function.static <T> Flow.Publisher<T>
suspendablePublisher(Flow.Publisher<T> delegatePublisher, Runnable onFirstSubscriptionRequest, Runnable onLastSubscriptionCancel)
Creates aFlow.Publisher
which wraps the provided one and also supports "active" and "suspended" states.
-
-
-
Method Detail
-
createReader
public static Reader createReader(Readable readable) throws IOException
Creates aReader
from the givenReadable
object.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.Subscriber
that will delegateFlow.Subscriber.onNext(Object)
to the specifiedonNextFunction
function.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
onNextFunction
should returnfalse
in order tocancel
current subscription.- Type Parameters:
T
- the type of the items provided by the subscription- Parameters:
onNextFunction
- function to be invoked duringonNext
processing- Returns:
Subscriber
that delegates itsonNext
to the caller-provided function
-
suspendablePublisher
public static <T> Flow.Publisher<T> suspendablePublisher(Flow.Publisher<T> delegatePublisher, Runnable onFirstSubscriptionRequest, Runnable onLastSubscriptionCancel)
Creates aFlow.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 thePublisher
transitions into the "active" state and invokes the caller-suppliedonFirstSubscriptionRequest
Runnable
. When the last subscriber cancels the returnedPublisher
transitions into the "suspended" state and invokes the caller-providedonLastSubscriptionCancel
Runnable
.- 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
-
-