from typing import Any, Dict, Union from geniusweb.issuevalue.Value import Value NoneType=type(None) class Bid: def __init__(self, issuevalues:Dict[str, Value]): ''' FIXME use strict typing ''' for (iss,val) in issuevalues.items(): if not isinstance(iss, str): raise ValueError("Issue "+str(iss)+" must be a str") if not isinstance(val, Value): raise ValueError("value "+str(val)+" must be a Value, but is "+str(type(val))) self._issuevalues = dict(issuevalues) #shallow copy : Value is immutable def getIssueValues(self) -> Dict[str, Value]: return self._issuevalues def getIssues(self): return self._issuevalues.keys() def getValue(self, issue:str) -> Union[Value,NoneType] : ''' @param issue name of the issue @return the value for the given issue, or null if there is no value for the given issue. ''' if not issue in self._issuevalues: return None return self._issuevalues[issue]; def __eq__(self, other): return isinstance(other, self.__class__) and \ self._issuevalues == other._issuevalues def __repr__(self) -> str: return "Bid" + repr( self._issuevalues); def __hash__(self): return hash((tuple(self._issuevalues.items())))