package net.minecraft.client;

import javax.annotation.Nullable;
import com.google.common.collect.Lists;
import net.minecraft.network.chat.FormattedText;
import java.util.List;

public class ComponentCollector {
    private final List<FormattedText> parts;
    
    public ComponentCollector() {
        this.parts = Lists.newArrayList();
    }
    
    public void append(final FormattedText mu) {
        this.parts.add(mu);
    }
    
    @Nullable
    public FormattedText getResult() {
        if (this.parts.isEmpty()) {
            return null;
        }
        if (this.parts.size() == 1) {
            return this.parts.get(0);
        }
        return FormattedText.composite(this.parts);
    }
    
    public FormattedText getResultOrEmpty() {
        final FormattedText mu2 = this.getResult();
        return (mu2 != null) ? mu2 : FormattedText.EMPTY;
    }
}
