Changeset 111 for geniuswebcore/geniusweb/actions/ActionWithBid.py
- Timestamp:
- Jul 23, 2025, 10:18:43 AM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
geniuswebcore/geniusweb/actions/ActionWithBid.py
r100 r111 1 from typing import Dict, Any 1 # Generated from java by J2P 2 from __future__ import annotations 2 3 from geniusweb.actions.AbstractAction import AbstractAction 3 4 from geniusweb.actions.PartyId import PartyId 4 5 from geniusweb.issuevalue.Bid import Bid 6 from tudelft.utilities.tools.safehash import safehash 7 from typing import Any 8 from typing import Optional 9 from typing import cast 5 10 6 11 7 class ActionWithBid ( AbstractAction ): 8 ''' 9 An {@link Action} containing a bid. Note that the presense of a bid does not 10 necessarily mean that an offer was placed for this bid. 12 class ActionWithBid(AbstractAction): 13 ''' 14 An {@link Action} containing a bid. Note that the presence of a bid does not 15 necessarily mean that an offer was placed for this bid. 16 11 17 12 ''' 18 ''' 19 20 def __init__(self, actor:PartyId, bid:Bid): 21 self.__bid:Bid = None 22 super().__init__(actor) 23 if (bid is None): 24 raise ValueError("bid is null") 25 self.__bid=bid 26 27 def getBid(self) -> Bid: 28 ''' 29 30 @return the {@link Bid} that this action is about. 13 31 14 def __init__(self, actor:PartyId, bid:Bid): 15 ''' 16 @param param the actor partyid: 17 @param bid the bid. FIXME use Bid object and strong typing 18 ''' 19 super().__init__(actor) 20 self._bid = bid 32 ''' 33 return self.__bid 34 35 #Override 36 def __hash__(self) -> int: 37 prime:int = 31 38 result:int = safehash(super()) 39 result=((prime * result) + (0 if ((self.__bid is None)) else safehash(self.__bid))) 40 return result 41 42 #Override 43 def __eq__(self,obj:Optional[Any]) -> bool: 44 ''' 45 This should work also for derived classes without extra fields. 21 46 22 def getBid(self) -> Bid: 23 ''' 24 @return the {@link Bid} that this action is about. 25 ''' 26 return self._bid; 27 28 def __eq__(self, other): 29 return isinstance(other, self.__class__) and \ 30 super().__eq__(other) and self._bid==other._bid 31 32 def __hash__(self): 33 return hash((self._actor, self._bid)) 34 47 ''' 48 if (self is obj): 49 return True 50 if not(super().__eq__(obj)): 51 return False 52 if (type(self) is not type(obj)): 53 return False 54 other:Optional[ActionWithBid] = cast(ActionWithBid,obj) 55 if (self.__bid is None): 56 if (other.__bid is not None): 57 return False 58 else: 59 if not(self.__bid == other.__bid): 60 return False 61 return True
Note:
See TracChangeset
for help on using the changeset viewer.