@dataclass
class NamedType(AbstractType):
name: str
@classmethod
def from_json(cls, json: Any) -> Optional[NamedType]:
if json.get("kind", "") == cls.__name__:
return NamedType(json["name"])
return None
@classmethod
def from_string(cls, string: str) -> NamedType:
return NamedType(string)
def to_json(self) -> dict[str, str]:
return {"kind": self.__class__.__name__, "name": self.name}
def __eq__(self, other: object) -> bool:
if isinstance(other, self.__class__):
return self.name == other.name
return False
def __hash__(self) -> int:
return hash(self.name)