2828from typing import Any , Dict , List , Optional , Set
2929import logging
3030
31- from .. import constants
3231from .stream import DataStreamReader
32+ from ..constants import ClassDescFlags , TypeCode
3333from ..modifiedutf8 import decode_modified_utf8
34+ from ..utils import UNICODE_TYPE
3435
3536
3637class ContentType (IntEnum ):
@@ -62,16 +63,16 @@ class FieldType(IntEnum):
6263 Types of class fields
6364 """
6465
65- BYTE = constants .TYPE_BYTE
66- CHAR = constants .TYPE_CHAR
67- DOUBLE = constants .TYPE_DOUBLE
68- FLOAT = constants .TYPE_FLOAT
69- INTEGER = constants .TYPE_INTEGER
70- LONG = constants .TYPE_LONG
71- SHORT = constants .TYPE_SHORT
72- BOOLEAN = constants .TYPE_BOOLEAN
73- ARRAY = constants .TYPE_ARRAY
74- OBJECT = constants .TYPE_OBJECT
66+ BYTE = TypeCode .TYPE_BYTE . value
67+ CHAR = TypeCode .TYPE_CHAR . value
68+ DOUBLE = TypeCode .TYPE_DOUBLE . value
69+ FLOAT = TypeCode .TYPE_FLOAT . value
70+ INTEGER = TypeCode .TYPE_INTEGER . value
71+ LONG = TypeCode .TYPE_LONG . value
72+ SHORT = TypeCode .TYPE_SHORT . value
73+ BOOLEAN = TypeCode .TYPE_BOOLEAN . value
74+ ARRAY = TypeCode .TYPE_ARRAY . value
75+ OBJECT = TypeCode .TYPE_OBJECT . value
7576
7677
7778class ParsedJavaContent :
@@ -280,7 +281,7 @@ def validate(self):
280281 Checks the validity of this class description
281282 """
282283 serial_or_extern = (
283- constants .SC_SERIALIZABLE | constants .SC_EXTERNALIZABLE
284+ ClassDescFlags .SC_SERIALIZABLE | ClassDescFlags .SC_EXTERNALIZABLE
284285 )
285286 if (self .desc_flags & serial_or_extern ) == 0 and self .fields :
286287 raise ValueError (
@@ -290,7 +291,7 @@ def validate(self):
290291 if self .desc_flags & serial_or_extern == serial_or_extern :
291292 raise ValueError ("Class is both serializable and externalizable" )
292293
293- if self .desc_flags & constants .SC_ENUM :
294+ if self .desc_flags & ClassDescFlags .SC_ENUM :
294295 if self .fields or self .interfaces :
295296 raise ValueError (
296297 "Enums shouldn't implement interfaces "
@@ -453,3 +454,14 @@ def __str__(self):
453454 )
454455
455456 __repr__ = __str__
457+
458+ def __eq__ (self , other ):
459+ if isinstance (other , (str , UNICODE_TYPE )):
460+ other_data = other .encode ("latin1" )
461+ elif isinstance (other , bytes ):
462+ other_data = other
463+ else :
464+ # Can't compare
465+ return False
466+
467+ return other_data == self .data
0 commit comments