public class SystemPropertySupplier<T>
extends java.lang.Object
implements java.util.function.Supplier<T>
It provides for:
Predicate)
The supported types are: Boolean, Integer, Long, String
| Modifier and Type | Method and Description |
|---|---|
static <U> SystemPropertySupplier<U> |
create(@NotNull java.lang.String propName,
U defaultValue)
Create it for a given property name and default value.
|
SystemPropertySupplier<T> |
formatSetMessage(@NotNull java.util.function.BiFunction<java.lang.String,T,java.lang.String> setMessageFormatter)
Specify a formatter for the "success" log message to be used when the
returned property value differs from the default.
|
T |
get()
Obtains the value of a system property, optionally generating
diagnostics.
|
SystemPropertySupplier<T> |
loggingTo(@NotNull org.slf4j.Logger log)
Specify the
Logger to log to (defaults to this classes logger otherwise). |
SystemPropertySupplier<T> |
logSuccessAs(org.slf4j.event.Level successLogLevel)
Specify
Level to use for "success" message. |
protected SystemPropertySupplier<T> |
usingSystemPropertyReader(@NotNull java.util.function.Function<java.lang.String,java.lang.String> sysPropReader)
For unit testing: specify a function to read system properties
(overriding default of
System.getProperty(String). |
SystemPropertySupplier<T> |
validateWith(@NotNull java.util.function.Predicate<T> validator)
Specify a validation expression.
|
public static <U> SystemPropertySupplier<U> create(@NotNull @NotNull java.lang.String propName, @NotNull U defaultValue) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic SystemPropertySupplier<T> loggingTo(@NotNull @NotNull org.slf4j.Logger log)
Logger to log to (defaults to this classes logger otherwise).public SystemPropertySupplier<T> validateWith(@NotNull @NotNull java.util.function.Predicate<T> validator)
public SystemPropertySupplier<T> formatSetMessage(@NotNull @NotNull java.util.function.BiFunction<java.lang.String,T,java.lang.String> setMessageFormatter)
public SystemPropertySupplier<T> logSuccessAs(org.slf4j.event.Level successLogLevel)
Level to use for "success" message.protected SystemPropertySupplier<T> usingSystemPropertyReader(@NotNull @NotNull java.util.function.Function<java.lang.String,java.lang.String> sysPropReader)
System.getProperty(String).Copyright © 2012–2022 The Apache Software Foundation. All rights reserved.