Last change
on this file since 74 was 73, checked in by Bart Vastenhouw, 3 years ago |
Fix for IssueValue hashcode.
|
File size:
586 bytes
|
Rev | Line | |
---|
[73] | 1 | from pyson.JsonValue import JsonValue
|
---|
| 2 |
|
---|
| 3 | from geniusweb.issuevalue.Value import Value
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | class DiscreteValue (Value) :
|
---|
| 7 | '''
|
---|
| 8 | A value for a discrete issue. Constructor guarantees this is non-null and
|
---|
| 9 | non-empty. immutable.
|
---|
| 10 | '''
|
---|
| 11 |
|
---|
| 12 | def __init__(self, value:str):
|
---|
| 13 | if value == None or value=="":
|
---|
| 14 | raise ValueError("value must be non-null and non-empty")
|
---|
| 15 | super().__init__(value)
|
---|
| 16 |
|
---|
| 17 | def __hash__(self):
|
---|
| 18 | return hash(self._value)
|
---|
| 19 |
|
---|
| 20 | def __repr__(self):
|
---|
| 21 | return '"'+str(self._value)+'"'
|
---|
| 22 |
|
---|
| 23 | def __eq__(self, other):
|
---|
| 24 | return isinstance(other, self.__class__) and self._value == other._value
|
---|
Note:
See
TracBrowser
for help on using the repository browser.