Last change
on this file since 404 was 404, checked in by wouter, 2 years ago |
#122 refactoring, creating separate packages for java core and jackson-translator (jackson-t)
|
File size:
868 bytes
|
Line | |
---|
1 | from typing import cast
|
---|
2 | import sys
|
---|
3 | from typing import List
|
---|
4 |
|
---|
5 | class ObjectFunctions:
|
---|
6 | '''
|
---|
7 | Basic object functions that have special translations: hashcode, equals,
|
---|
8 | toString.
|
---|
9 |
|
---|
10 | '''
|
---|
11 | def __init__(self, a:int):
|
---|
12 | self.__a:int
|
---|
13 | self.__a=a
|
---|
14 | #Override
|
---|
15 | def __repr__(self) -> str:
|
---|
16 | return str(self.__a)
|
---|
17 | #Override
|
---|
18 | def __hash__(self) -> int:
|
---|
19 | return self.__a
|
---|
20 | #Override
|
---|
21 | def __eq__(self,obj:type) -> bool:
|
---|
22 | if self is obj:
|
---|
23 | return True
|
---|
24 | if obj is None:
|
---|
25 | return False
|
---|
26 | if type(self) is not type(obj):
|
---|
27 | return False
|
---|
28 | other:ObjectFunctions = cast(ObjectFunctions,obj)
|
---|
29 | return self.__a is other.__a
|
---|
30 | @staticmethod
|
---|
31 | def main(args:List[str]) -> None:
|
---|
32 | v:ObjectFunctions = ObjectFunctions(12)
|
---|
33 | v2:ObjectFunctions = ObjectFunctions(12)
|
---|
34 | sys.stdout.write(str(v) + str(v.__eq__(v2)) + str(hash(v))+'\n')
|
---|
35 | if __name__ == "__main__":
|
---|
36 | ObjectFunctions.main(sys.argv[1:])
|
---|
Note:
See
TracBrowser
for help on using the repository browser.