
package dev.sonpx.loyalty.mcp.model.valueobject;

public class BooleanValue extends BaseValue<Boolean> {

    public static final BooleanValue FALSE = new BooleanValue(false);

    BooleanValue(Boolean value) {
        super(value);
    }

    public boolean isEqualTo(BooleanValue compareValue) {
        return this.value.equals(compareValue.getValue());
    }

    public static BooleanValue of(Object value) {
        BooleanValue falseValue = BooleanValue.FALSE;
        if (value instanceof Boolean bool) {
            return new BooleanValue(bool);
        } else if (value instanceof String string) {
            try {
                return BooleanValue.of(Boolean.valueOf(string));
            } catch (Exception ignored) {
                //
            }
        }
        return falseValue;
    }
}
