# Code generated by Lark OpenAPI.

from typing import Any, Optional, Union, Dict, List, Set, IO, Callable, Type
from lark_oapi.core.construct import init
from .range_filter import RangeFilter
from .candidate_tag_filter import CandidateTagFilter
from .degree_filter import DegreeFilter


class Filter(object):
    _types = {
        "key": str,
        "value_type": int,
        "value_list": List[str],
        "range_filter": RangeFilter,
        "candidate_tag_filter": CandidateTagFilter,
        "degree_filter": DegreeFilter,
    }

    def __init__(self, d=None):
        self.key: Optional[str] = None
        self.value_type: Optional[int] = None
        self.value_list: Optional[List[str]] = None
        self.range_filter: Optional[RangeFilter] = None
        self.candidate_tag_filter: Optional[CandidateTagFilter] = None
        self.degree_filter: Optional[DegreeFilter] = None
        init(self, d, self._types)

    @staticmethod
    def builder() -> "FilterBuilder":
        return FilterBuilder()


class FilterBuilder(object):
    def __init__(self) -> None:
        self._filter = Filter()

    def key(self, key: str) -> "FilterBuilder":
        self._filter.key = key
        return self

    def value_type(self, value_type: int) -> "FilterBuilder":
        self._filter.value_type = value_type
        return self

    def value_list(self, value_list: List[str]) -> "FilterBuilder":
        self._filter.value_list = value_list
        return self

    def range_filter(self, range_filter: RangeFilter) -> "FilterBuilder":
        self._filter.range_filter = range_filter
        return self

    def candidate_tag_filter(self, candidate_tag_filter: CandidateTagFilter) -> "FilterBuilder":
        self._filter.candidate_tag_filter = candidate_tag_filter
        return self

    def degree_filter(self, degree_filter: DegreeFilter) -> "FilterBuilder":
        self._filter.degree_filter = degree_filter
        return self

    def build(self) -> "Filter":
        return self._filter
