renamed package to pypattyrn
This commit is contained in:
75
pypattyrn/behavioral/null.py
Normal file
75
pypattyrn/behavioral/null.py
Normal file
@@ -0,0 +1,75 @@
|
||||
class Null(object):
|
||||
"""
|
||||
A Null object class as part of the Null object design pattern.
|
||||
|
||||
- External Usage documentation: U{https://github.com/tylerlaberge/PyPatterns/wiki/Behavioral-Pattern-Usage}
|
||||
- External Null Object Pattern documentation: U{https://en.wikipedia.org/wiki/Null_Object_pattern}
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Do nothing.
|
||||
"""
|
||||
pass
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
"""
|
||||
Do nothing.
|
||||
|
||||
@return: This object instance.
|
||||
@rtype: Null
|
||||
"""
|
||||
return self
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""
|
||||
Do nothing.
|
||||
|
||||
@return: This object instance.
|
||||
@rtype: Null
|
||||
"""
|
||||
return self
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
"""
|
||||
Do nothing.
|
||||
|
||||
@return: This object instance.
|
||||
@rtype: Null
|
||||
"""
|
||||
return self
|
||||
|
||||
def __delattr__(self, name):
|
||||
"""
|
||||
Do nothing.
|
||||
|
||||
@return: This object instance.
|
||||
@rtype: Null
|
||||
"""
|
||||
return self
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
Null object string representation is the empty string.
|
||||
|
||||
@return: An empty string.
|
||||
@rtype: String
|
||||
"""
|
||||
return ''
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
Null object string representation is the empty string.
|
||||
|
||||
@return: An empty string.
|
||||
@rtype: String
|
||||
"""
|
||||
return ''
|
||||
|
||||
def __bool__(self):
|
||||
"""
|
||||
Null object evaluates to False.
|
||||
|
||||
@return: False.
|
||||
@rtype: Boolean
|
||||
"""
|
||||
return False
|
||||
Reference in New Issue
Block a user