package net.minecraft.util.profiling;

import java.util.function.Supplier;

public interface ProfilerFiller {
    void startTick();
    
    void endTick();
    
    void push(final String string);
    
    void push(final Supplier<String> supplier);
    
    void pop();
    
    void popPush(final String string);
    
    void popPush(final Supplier<String> supplier);
    
    void incrementCounter(final String string);
    
    void incrementCounter(final Supplier<String> supplier);
    
    default ProfilerFiller tee(final ProfilerFiller ami1, final ProfilerFiller ami2) {
        if (ami1 == InactiveProfiler.INSTANCE) {
            return ami2;
        }
        if (ami2 == InactiveProfiler.INSTANCE) {
            return ami1;
        }
        return new ProfilerFiller() {
            @Override
            public void startTick() {
                ami1.startTick();
                ami2.startTick();
            }
            
            @Override
            public void endTick() {
                ami1.endTick();
                ami2.endTick();
            }
            
            @Override
            public void push(final String string) {
                ami1.push(string);
                ami2.push(string);
            }
            
            @Override
            public void push(final Supplier<String> supplier) {
                ami1.push(supplier);
                ami2.push(supplier);
            }
            
            @Override
            public void pop() {
                ami1.pop();
                ami2.pop();
            }
            
            @Override
            public void popPush(final String string) {
                ami1.popPush(string);
                ami2.popPush(string);
            }
            
            @Override
            public void popPush(final Supplier<String> supplier) {
                ami1.popPush(supplier);
                ami2.popPush(supplier);
            }
            
            @Override
            public void incrementCounter(final String string) {
                ami1.incrementCounter(string);
                ami2.incrementCounter(string);
            }
            
            @Override
            public void incrementCounter(final Supplier<String> supplier) {
                ami1.incrementCounter(supplier);
                ami2.incrementCounter(supplier);
            }
        };
    }
}
