package com.r35157.jupiterperpsalarm.impl.ref;

import java.math.BigDecimal;
import java.util.Objects;

public record ComparisonPriceCondition(
        PriceComparisonOperator operator,
        BigDecimal target
) implements PriceCondition {

    public ComparisonPriceCondition {
        Objects.requireNonNull(operator, "operator");
        Objects.requireNonNull(target, "target");
    }

    @Override
    public boolean matches(BigDecimal price) {
        return operator.matches(price, target);
    }

    @Override
    public String expression() {
        return operator.symbol() + target.toPlainString();
    }
}
