package net.minecraft.network.chat;

import java.util.Objects;
import com.google.common.collect.Streams;
import java.util.function.Function;
import java.util.stream.Stream;
import java.util.Iterator;
import com.google.common.collect.Lists;
import java.util.List;

public abstract class BaseComponent implements Component {
    protected final List<Component> siblings;
    private Style style;
    
    public BaseComponent() {
        this.siblings = Lists.newArrayList();
    }
    
    @Override
    public Component append(final Component lf) {
        lf.getStyle().inheritFrom(this.getStyle());
        this.siblings.add(lf);
        return this;
    }
    
    @Override
    public List<Component> getSiblings() {
        return this.siblings;
    }
    
    @Override
    public Component setStyle(final Style ln) {
        this.style = ln;
        for (final Component lf4 : this.siblings) {
            lf4.getStyle().inheritFrom(this.getStyle());
        }
        return this;
    }
    
    @Override
    public Style getStyle() {
        if (this.style == null) {
            this.style = new Style();
            for (final Component lf3 : this.siblings) {
                lf3.getStyle().inheritFrom(this.style);
            }
        }
        return this.style;
    }
    
    @Override
    public Stream<Component> stream() {
        return Streams.<Component>concat(new Stream[] { Stream.<BaseComponent>of(this), this.siblings.stream().flatMap(Component::stream) });
    }
    
    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        }
        if (object instanceof BaseComponent) {
            final BaseComponent lc3 = (BaseComponent)object;
            return this.siblings.equals(lc3.siblings) && this.getStyle().equals(lc3.getStyle());
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(this.getStyle(), this.siblings);
    }
    
    @Override
    public String toString() {
        return "BaseComponent{style=" + this.style + ", siblings=" + this.siblings + '}';
    }
}
