package com.google.firebase.database.collection;

import com.google.firebase.database.collection.LLRBNode;

/* JADX INFO: loaded from: classes3.dex */
public class LLRBBlackValueNode<K, V> extends LLRBValueNode<K, V> {
    private int size;

    public LLRBBlackValueNode(K k6, V v3, LLRBNode<K, V> lLRBNode, LLRBNode<K, V> lLRBNode2) {
        super(k6, v3, lLRBNode, lLRBNode2);
        this.size = -1;
    }

    @Override // com.google.firebase.database.collection.LLRBValueNode
    public LLRBValueNode<K, V> copy(K k6, V v3, LLRBNode<K, V> lLRBNode, LLRBNode<K, V> lLRBNode2) {
        if (k6 == null) {
            k6 = getKey();
        }
        if (v3 == null) {
            v3 = getValue();
        }
        if (lLRBNode == null) {
            lLRBNode = getLeft();
        }
        if (lLRBNode2 == null) {
            lLRBNode2 = getRight();
        }
        return new LLRBBlackValueNode(k6, v3, lLRBNode, lLRBNode2);
    }

    @Override // com.google.firebase.database.collection.LLRBValueNode
    public LLRBNode.Color getColor() {
        return LLRBNode.Color.BLACK;
    }

    @Override // com.google.firebase.database.collection.LLRBNode
    public boolean isRed() {
        return false;
    }

    @Override // com.google.firebase.database.collection.LLRBValueNode
    public void setLeft(LLRBNode<K, V> lLRBNode) {
        if (this.size != -1) {
            throw new IllegalStateException("Can't set left after using size");
        }
        super.setLeft(lLRBNode);
    }

    @Override // com.google.firebase.database.collection.LLRBNode
    public int size() {
        if (this.size == -1) {
            this.size = getRight().size() + getLeft().size() + 1;
        }
        return this.size;
    }
}
