namespace InABox.Avalonia.Converters;

public enum MatchComparison
{
    EqualTo,
    NotEqualTo
}

public enum MatchType
{
    Any,
    All
}
    
public class AbstractMatcher<T> : AbstractMultiConverter<T,bool>
{
    public MatchComparison Comparison { get; set; }
        
    public MatchType Type { get; set; }
        
    public T Value { get; set; }
        
    protected override bool Convert(IEnumerable<T> value, object parameter = null)
    {
        var result = Type switch
        {
            MatchType.Any => Comparison == MatchComparison.EqualTo
                ? value.Any(x => Equals(Value, x))
                : value.Any(x => !Equals(Value, x)),
            MatchType.All => Comparison == MatchComparison.EqualTo
                ? value.All(x => Equals(Value, x))
                : value.All(x => !Equals(Value, x)),
            _ => false
        };
        return result;
    }
}