// 
// Decompiled by Procyon v0.6.0
// 

package com.google.protobuf;

public final class ProtobufToStringOutput
{
    private static final ThreadLocal<OutputMode> outputMode;
    
    private ProtobufToStringOutput() {
    }
    
    private static OutputMode setOutputMode(final OutputMode newMode) {
        final OutputMode oldMode = ProtobufToStringOutput.outputMode.get();
        ProtobufToStringOutput.outputMode.set(newMode);
        return oldMode;
    }
    
    private static void callWithSpecificFormat(final Runnable impl, final OutputMode mode) {
        final OutputMode oldMode = setOutputMode(mode);
        try {
            impl.run();
        }
        finally {
            setOutputMode(oldMode);
        }
    }
    
    public static void callWithDebugFormat(final Runnable impl) {
        callWithSpecificFormat(impl, OutputMode.DEBUG_FORMAT);
    }
    
    public static void callWithTextFormat(final Runnable impl) {
        callWithSpecificFormat(impl, OutputMode.TEXT_FORMAT);
    }
    
    public static boolean shouldOutputDebugFormat() {
        return ProtobufToStringOutput.outputMode.get() == OutputMode.DEBUG_FORMAT;
    }
    
    public static boolean isDefaultFormat() {
        return ProtobufToStringOutput.outputMode.get() == OutputMode.DEFAULT_FORMAT;
    }
    
    static {
        outputMode = ThreadLocal.withInitial(() -> OutputMode.DEFAULT_FORMAT);
    }
    
    private enum OutputMode
    {
        DEBUG_FORMAT, 
        TEXT_FORMAT, 
        DEFAULT_FORMAT;
    }
}
