379364d09844536d144f40b3cd9da9957f3dd4fb
[smartapi.git] / Common / Python / SmartAPI / model / DependentPriceSpecification.py
1 from SmartAPI.common.PROPERTY import PROPERTY
2
3 from SmartAPI.model.PriceSpecification import PriceSpecification
4 from SmartAPI.model.Condition import Condition
5
6
7 class DependentPriceSpecification(PriceSpecification):
8
9         def __init__(self, uri = None, value = None, unit = None, validFrom = None, validThrough = None):
10                 super(DependentPriceSpecification, self).__init__(uri = uri, value = value, unit = unit, validFrom = validFrom, validThrough = validThrough)
11                 self.init_property(PROPERTY.LIST, 'conditions', self.hasCondition, self.getConditions, islist = True)
12         
13         def hasCondition(self):
14                 return len(self.conditions) > 0
15                 
16         def getConditions(self):
17                 return self.conditions
18
19         def addCondition(self, c):
20                 self.conditions.append(c)
21
22         def _parseStatement(self, statement, custom_classes = None):
23                 self.parse_property(statement, PROPERTY.LIST, self.addCondition, Condition, custom_classes = custom_classes)
24                 super(DependentPriceSpecification, self)._parseStatement(statement, custom_classes = custom_classes)