// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.eventgrid.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/**
 * This is the base type that represents a filter. To configure a filter, do not directly instantiate an object of this
 * class. Instead, instantiate an object of a derived class such as BoolEqualsFilter, NumberInFilter, StringEqualsFilter
 * etc depending on the type of the key based on which you want to filter.
 */
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "operatorType",
    defaultImpl = Filter.class)
@JsonTypeName("Filter")
@JsonSubTypes({
    @JsonSubTypes.Type(name = "NumberIn", value = NumberInFilter.class),
    @JsonSubTypes.Type(name = "NumberNotIn", value = NumberNotInFilter.class),
    @JsonSubTypes.Type(name = "NumberLessThan", value = NumberLessThanFilter.class),
    @JsonSubTypes.Type(name = "NumberGreaterThan", value = NumberGreaterThanFilter.class),
    @JsonSubTypes.Type(name = "NumberLessThanOrEquals", value = NumberLessThanOrEqualsFilter.class),
    @JsonSubTypes.Type(name = "NumberGreaterThanOrEquals", value = NumberGreaterThanOrEqualsFilter.class),
    @JsonSubTypes.Type(name = "BoolEquals", value = BoolEqualsFilter.class),
    @JsonSubTypes.Type(name = "StringIn", value = StringInFilter.class),
    @JsonSubTypes.Type(name = "StringNotIn", value = StringNotInFilter.class),
    @JsonSubTypes.Type(name = "StringBeginsWith", value = StringBeginsWithFilter.class),
    @JsonSubTypes.Type(name = "StringEndsWith", value = StringEndsWithFilter.class),
    @JsonSubTypes.Type(name = "StringContains", value = StringContainsFilter.class),
    @JsonSubTypes.Type(name = "NumberInRange", value = NumberInRangeFilter.class),
    @JsonSubTypes.Type(name = "NumberNotInRange", value = NumberNotInRangeFilter.class),
    @JsonSubTypes.Type(name = "StringNotBeginsWith", value = StringNotBeginsWithFilter.class),
    @JsonSubTypes.Type(name = "StringNotEndsWith", value = StringNotEndsWithFilter.class),
    @JsonSubTypes.Type(name = "StringNotContains", value = StringNotContainsFilter.class),
    @JsonSubTypes.Type(name = "IsNullOrUndefined", value = IsNullOrUndefinedFilter.class),
    @JsonSubTypes.Type(name = "IsNotNull", value = IsNotNullFilter.class)
})
@Fluent
public class Filter {
    /*
     * The field/property in the event based on which you want to filter.
     */
    @JsonProperty(value = "key")
    private String key;

    /** Creates an instance of Filter class. */
    public Filter() {
    }

    /**
     * Get the key property: The field/property in the event based on which you want to filter.
     *
     * @return the key value.
     */
    public String key() {
        return this.key;
    }

    /**
     * Set the key property: The field/property in the event based on which you want to filter.
     *
     * @param key the key value to set.
     * @return the Filter object itself.
     */
    public Filter withKey(String key) {
        this.key = key;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
    }
}
