#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from Utils.Patterns import RE
from typing import Any, Optional, Self

class Check:

    @staticmethod
    def is_string(item:Optional[Any]) -> bool:
        return isinstance(item, str) and not isinstance(item, bytes)
    
    @classmethod
    def is_key(cls:type[Self], item:Optional[Any]) -> bool:
        return cls.is_string(item) and RE.KEY.match(item) is not None
    
    @staticmethod
    def is_dictionary(item:Optional[Any]) -> bool:
        return isinstance(item, dict)
    
    @staticmethod
    def is_array(item:Optional[Any]) -> bool:
        return isinstance(item, (list, tuple))
    
    @staticmethod
    def is_integer(item:Optional[Any]) -> bool:
        return isinstance(item, int)
    
    @staticmethod
    def is_float(item:Optional[Any]) -> bool:
        return isinstance(item, float)
    
    @staticmethod
    def is_number(item:Optional[Any]) -> bool:
        return isinstance(item, (int, float))
    
    @staticmethod
    def is_bytes(item:Optional[Any]) -> bool:
        return isinstance(item, bytes)
    
    @staticmethod
    def is_json_object(item:Optional[Any]) -> bool:
        return isinstance(item, (dict, list, tuple))