mirror of
https://github.com/yweber/lodel2.git
synced 2025-11-27 15:56:53 +01:00
Implements an empty() classmethod for multiref datahandlers
Return the value of this datahandler when empty
This commit is contained in:
parent
0b443a6d93
commit
61e892fe61
2 changed files with 22 additions and 0 deletions
|
|
@ -368,6 +368,12 @@ class MultipleRef(Reference):
|
|||
def __init__(self, max_item = None, **kwargs):
|
||||
self.max_item = max_item
|
||||
super().__init__(**kwargs)
|
||||
|
||||
##@brief Method designed to return an empty value for this kind of
|
||||
#multipleref
|
||||
@classmethod
|
||||
def empty(cls):
|
||||
return None
|
||||
|
||||
##@brief Check and cast value in appropriate type
|
||||
#@param value *
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ class List(MultipleRef):
|
|||
def __init__(self, max_length = None, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@classmethod
|
||||
def empty(cls):
|
||||
return list()
|
||||
|
||||
##@brief Check and cast value in appropriate type
|
||||
#@param value *
|
||||
#@throw FieldValidationError if value is unappropriate or can not be cast
|
||||
|
|
@ -37,6 +41,10 @@ class Set(MultipleRef):
|
|||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@classmethod
|
||||
def empty(cls):
|
||||
return set()
|
||||
|
||||
##@brief Check and cast value in appropriate type
|
||||
#@param value *
|
||||
#@throw FieldValidationError if value is unappropriate or can not be cast
|
||||
|
|
@ -57,6 +65,10 @@ class Map(MultipleRef):
|
|||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@classmethod
|
||||
def empty(cls):
|
||||
return dict()
|
||||
|
||||
##@brief Check and cast value in appropriate type
|
||||
#@param value *
|
||||
#@throw FieldValidationError if value is unappropriate or can not be cast
|
||||
|
|
@ -81,6 +93,10 @@ class Hierarch(MultipleRef):
|
|||
max_childs = max_childs,
|
||||
**kwargs)
|
||||
|
||||
@classmethod
|
||||
def empty(cls):
|
||||
return tuple()
|
||||
|
||||
##@brief Check and cast value in appropriate type
|
||||
#@param value *
|
||||
#@throw FieldValidationError if value is unappropriate or can not be cast
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue