source: geniuswebcore/geniusweb/party/Capabilities.py

Last change on this file was 111, checked in by ruud, 2 months ago

Modifications for automatic java to python conversion. Overloaded methods now have different names.

File size: 2.5 KB
Line 
1# Generated from java by J2P
2from __future__ import annotations
3from geniusweb.profile.Profile import Profile
4from tudelft.utilities.tools.safehash import safehash
5from typing import Any
6from typing import Optional
7from typing import Set
8from typing import Type
9from typing import cast
10
11
12# not used in python
13# not used in python
14class Capabilities:
15 '''
16 The profile classes that are supported
17 The capabilities of a party
18
19 '''
20
21 def __init__(self, behaviours:Set[str], profiles:Set[Type[Profile]]):
22 '''
23
24 @param behaviours the {@link ProtocolRef} that a Party can handle, as
25 returned by NegoProtocol.getRef()
26 @param profiles the {@link Profile} classes that Party acan handle
27
28 '''
29 '''
30 List of supported protocol names
31
32 '''
33
34 self.__behaviours:Set[str] = None
35 # not used in python
36 # not used in python
37 self.__profiles:Set[Type[Profile]] = None
38 super().__init__()
39 if (behaviours is None):
40 raise ValueError("behaviours==null")
41 for prof in profiles :
42 prof:Type[Profile] = prof
43 if not(issubclass(prof,Profile)):
44 raise ValueError("profile " + prof + " must be a subclass of Profile")
45 self.__behaviours=behaviours
46 self.__profiles=profiles
47
48 def getBehaviours(self) -> Optional[Set[Optional[str]]]:
49 '''
50
51 @return the behaviours (protocols) that are supported
52
53 '''
54 return frozenset(self.__behaviours)
55
56 def getProfiles(self) -> Set[Type[Profile]]:
57 '''
58
59 @return the profile classes that are supported
60
61
62 '''
63 return frozenset(self.__profiles)
64
65 #Override
66 def __hash__(self) -> int:
67 prime:int = 31
68 result:int = 1
69 result=((prime * result) + (0 if ((self.__behaviours is None)) else safehash(self.__behaviours)))
70 result=((prime * result) + (0 if ((self.__profiles is None)) else safehash(self.__profiles)))
71 return result
72
73 #Override
74 def __eq__(self,obj:Optional[Any]) -> bool:
75 if (self is obj):
76 return True
77 if (obj is None):
78 return False
79 if (type(self) is not type(obj)):
80 return False
81 other:Optional[Capabilities] = cast(Capabilities,obj)
82 if (self.__behaviours is None):
83 if (other.__behaviours is not None):
84 return False
85 else:
86 if not(self.__behaviours == other.__behaviours):
87 return False
88 if (self.__profiles is None):
89 if (other.__profiles is not None):
90 return False
91 else:
92 if not(self.__profiles == other.__profiles):
93 return False
94 return True
95
96 #Override
97 def __repr__(self) -> str:
98 return "Capabilities[" + str(self.__profiles) + "," + str(self.__behaviours) + "]"
Note: See TracBrowser for help on using the repository browser.