package net.minecraft.network.chat;

import javax.annotation.Nullable;
import net.minecraft.locale.Language;

public class TextComponent extends BaseComponent {
    public static final Component EMPTY;
    private final String text;
    @Nullable
    private Language decomposedWith;
    private String reorderedText;
    
    public TextComponent(final String string) {
        this.text = string;
        this.reorderedText = string;
    }
    
    public String getText() {
        return this.text;
    }
    
    @Override
    public String getContents() {
        if (this.text.isEmpty()) {
            return this.text;
        }
        final Language kz2 = Language.getInstance();
        if (this.decomposedWith != kz2) {
            this.reorderedText = kz2.reorder(this.text, false);
            this.decomposedWith = kz2;
        }
        return this.reorderedText;
    }
    
    @Override
    public TextComponent plainCopy() {
        return new TextComponent(this.text);
    }
    
    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        }
        if (object instanceof TextComponent) {
            final TextComponent nd3 = (TextComponent)object;
            return this.text.equals(nd3.getText()) && super.equals(object);
        }
        return false;
    }
    
    @Override
    public String toString() {
        return "TextComponent{text='" + this.text + '\'' + ", siblings=" + this.siblings + ", style=" + this.getStyle() + '}';
    }
    
    static {
        EMPTY = new TextComponent("");
    }
}
