package models.deltaAlgebra;

import java.util.ArrayList;
import java.util.List;

public class DeltaProduct extends DeltaCombination {
    private DeltaExpression left;
    private DeltaExpression right;

    public DeltaProduct(DeltaExpression left, DeltaExpression right) {
        this.left = left;
        this.right = right;
    }

    @Override
    public List<Delta> decompose() {
        List<Delta> deltas = new ArrayList<>(left.decompose());
        deltas.addAll(right.decompose());
        return deltas;
    }

    @Override
    public DeltaProduct copy() {
        return new DeltaProduct(left.copy(), right.copy());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || !(o instanceof DeltaProduct)) return false;
        DeltaProduct another = (DeltaProduct) o;
        return left.equals(another.left) && right.equals(another.right);
    }

    @Override
    public int hashCode() {
        return left.hashCode() + right.hashCode();
    }

    public String toString() {
        return left.toString() + " x " + right.toString();
    }
}
