Package net.sf.eBus.util
Class LazyString
- java.lang.Object
-
- net.sf.eBus.util.LazyString
-
@ThreadSafe public final class LazyString extends Object
DelaysStringgeneration untiltoString()method is called. This class is used to support lazy text generation inorg.slf4j.Loggerprior to version 2. (Note: slf4j does support lambda in version 2). Consider the following example:import org.slf4j.Logger; import org.slf4j.LoggerFactory; private static final Logger sLogger = LoggerFactory.getLogger(MyClass.class); final byte[] data = new byte[50_000]; // Initialize data byte array. sLogger.debug("data contents:\n{}", new LazyString(() -> HexDump.dump(data, " ");- Author:
- Charles W. Rapp
-
-
Constructor Summary
Constructors Constructor Description LazyString(Supplier<String> initializer)Creates a new, un-initialized lazy string instance using the givenStringsupplier to generate the text when needed.
-