All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tracee.contextlogger.api.WrappedContextLoggerOutput Maven / Gradle / Ivy

package io.tracee.contextlogger.api;

/**
 * Class for providing output at runtime via toString.
 */
public class WrappedContextLoggerOutput {

    private final ContextLogger traceeContextLogger;
    private String generatedOutput;
    private final Object[] instancesToOutput;

    private WrappedContextLoggerOutput(ContextLogger traceeContextLogger, Object... instancesToOutput) {
        this.traceeContextLogger = traceeContextLogger;
        this.instancesToOutput = instancesToOutput;
    }

    @Override
    public String toString() {
        if (generatedOutput == null) {
            generatedOutput = (traceeContextLogger != null ? traceeContextLogger.toString(instancesToOutput) : null);
        }

        return generatedOutput;
    }

    public static WrappedContextLoggerOutput wrap(ContextLogger traceeContextLogger, Object... instancesToOutput) {
        return new WrappedContextLoggerOutput(traceeContextLogger, instancesToOutput);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy