
package dev.sonpx.loyalty.mcp.filter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * Handle for filtering with basic operators (equals, notEquals, specified, in, notIn)
 */
@Getter
@NoArgsConstructor
@EqualsAndHashCode
public class Filter<T> implements Serializable {

    private T equals;
    private T notEquals;
    private Boolean specified;
    private List<T> in;
    private List<T> notIn;

    public Filter(Filter<T> filter) {
        this.equals = filter.equals;
        this.notEquals = filter.notEquals;
        this.specified = filter.specified;
        this.in = filter.in == null ? null : new ArrayList<>(filter.in);
        this.notIn = filter.notIn == null ? null : new ArrayList<>(filter.notIn);
    }

    public Filter<T> setEquals(T equals) {
        this.equals = equals;
        return this;
    }

    public Filter<T> setNotEquals(T notEquals) {
        this.notEquals = notEquals;
        return this;
    }

    public Filter<T> setSpecified(Boolean specified) {
        this.specified = specified;
        return this;
    }

    public Filter<T> setIn(List<T> in) {
        this.in = in;
        return this;
    }

    public Filter<T> setNotIn(List<T> notIn) {
        this.notIn = notIn;
        return this;
    }
}
