|
35 | 35 |
|
36 | 36 | # Standard library |
37 | 37 | import collections |
| 38 | +import functools |
38 | 39 | import logging |
39 | 40 | import os |
40 | 41 | import struct |
@@ -1712,32 +1713,35 @@ def __extra_loading__(self, unmarshaller, ident=0): |
1712 | 1713 | # Lists have their content in there annotations |
1713 | 1714 | self.extend(self.annotations[1:]) |
1714 | 1715 |
|
1715 | | - class JavaBool(JavaObject): |
| 1716 | + @functools.total_ordering |
| 1717 | + class JavaPrimitiveClass(JavaObject): |
| 1718 | + """ |
| 1719 | + Parent of Java classes matching a primitive (Bool, Integer, Long, ...) |
| 1720 | + """ |
1716 | 1721 | def __init__(self, unmarshaller): |
1717 | 1722 | JavaObject.__init__(self) |
1718 | 1723 | self.value = None |
1719 | | - pass |
1720 | 1724 |
|
1721 | 1725 | def __str__(self): |
1722 | | - return self.value.__str__() |
| 1726 | + return str(self.value) |
1723 | 1727 |
|
1724 | 1728 | def __repr__(self): |
1725 | | - return self.value.__repr__() |
1726 | | - |
1727 | | - def __bool__(self): |
1728 | | - return self.value |
| 1729 | + return repr(self.value) |
1729 | 1730 |
|
1730 | | - class JavaInt(JavaObject): |
1731 | | - def __init__(self, unmarshaller): |
1732 | | - self.value = None |
1733 | | - JavaObject.__init__(self) |
| 1731 | + def __hash__(self): |
| 1732 | + return hash(self.value) |
1734 | 1733 |
|
1735 | | - def __str__(self): |
1736 | | - return self.value.__str__() |
| 1734 | + def __eq__(self, other): |
| 1735 | + return self.value == other |
1737 | 1736 |
|
1738 | | - def __repr__(self): |
1739 | | - return self.value.__repr__() |
1740 | | - |
| 1737 | + def __lt__(self, other): |
| 1738 | + return self.value < other |
| 1739 | + |
| 1740 | + class JavaBool(JavaPrimitiveClass): |
| 1741 | + def __bool__(self): |
| 1742 | + return self.value |
| 1743 | + |
| 1744 | + class JavaInt(JavaPrimitiveClass): |
1741 | 1745 | def __int__(self): |
1742 | 1746 | return self.value |
1743 | 1747 |
|
|
0 commit comments