#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self):
self._seconds = []
def getSecond(self, index):
return self._seconds[index]
def getSeconds(self):
return tuple(self._seconds)
def numberOfSeconds(self):
return len(self._seconds)
def hasSeconds(self):
return len(self._seconds) > 0
def indexOfSecond(self, aSecond):
return next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
@staticmethod
def minimumNumberOfSeconds():
return 0
def addSecond(self, aSecond):
if any(x is aSecond for x in self._seconds):
return False
self._seconds.append(aSecond)
if aSecond.indexOfFirst(self) == -1 and not aSecond.addFirst(self):
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
return False
return True
def removeSecond(self, aSecond):
oldIndex = next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
if oldIndex == -1:
return False
del self._seconds[oldIndex]
if aSecond.indexOfFirst(self) != -1 and not aSecond.removeFirst(self):
self._seconds.insert(oldIndex, aSecond)
return False
return True
def addSecondAt(self, aSecond, index):
if not self.addSecond(aSecond):
return False
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def addOrMoveSecondAt(self, aSecond, index):
if not any(x is aSecond for x in self._seconds):
return self.addSecondAt(aSecond, index)
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def delete(self):
copyOfSeconds = tuple(self._seconds)
self._seconds.clear()
for aSecond in copyOfSeconds:
aSecond.removeFirst(self)
def setSecond(self, aSecond):
return False
def setSeconds(self, *newSeconds):
return False
def isNumberOfSecondsValid(self):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self, aSecond):
self._second = None
if not self.setSecond(aSecond):
raise RuntimeError("Unable to create first due to second. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
def getSecond(self):
return self._second
def setSecond(self, aSecond):
if aSecond is None:
return False
existingSecond = self._second
self._second = aSecond
if existingSecond is not None and existingSecond is not aSecond:
existingSecond.removeFirst(self)
self._second.addFirst(self)
return True
def delete(self):
placeholderSecond = self._second
self._second = None
if placeholderSecond is not None:
placeholderSecond.removeFirst(self)
def addSecond(self, aSecond):
return False
def getSeconds(self):
return None
def setSeconds(self, *newSeconds):
return False
def numberOfSeconds(self):
return 0
def hasSeconds(self):
return False
def indexOfSecond(self, second):
return 0
def isNumberOfSecondsValid(self):
return False
def removeSecond(self, second):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self, *allSeconds):
self._seconds = []
if not self.setSeconds(*allSeconds):
raise RuntimeError("Unable to create First, must have 1 to 5 seconds. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
def getSecond(self, index):
return self._seconds[index]
def getSeconds(self):
return tuple(self._seconds)
def numberOfSeconds(self):
return len(self._seconds)
def hasSeconds(self):
return len(self._seconds) > 0
def indexOfSecond(self, aSecond):
return next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
def isNumberOfSecondsValid(self):
return self.numberOfSeconds() >= __class__.minimumNumberOfSeconds() and self.numberOfSeconds() <= __class__.maximumNumberOfSeconds()
@staticmethod
def minimumNumberOfSeconds():
return 1
@staticmethod
def maximumNumberOfSeconds():
return 5
def addSecond(self, aSecond):
if any(x is aSecond for x in self._seconds):
return False
if self.numberOfSeconds() >= __class__.maximumNumberOfSeconds():
return False
self._seconds.append(aSecond)
if aSecond.indexOfFirst(self) == -1 and not aSecond.addFirst(self):
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
return False
return True
def removeSecond(self, aSecond):
oldIndex = next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
if oldIndex == -1:
return False
if self.numberOfSeconds() <= __class__.minimumNumberOfSeconds():
return False
del self._seconds[oldIndex]
if aSecond.indexOfFirst(self) != -1 and not aSecond.removeFirst(self):
self._seconds.insert(oldIndex, aSecond)
return False
return True
def setSeconds(self, *newSeconds):
if len({id(x) for x in newSeconds}) != len(newSeconds) or len(newSeconds) < __class__.minimumNumberOfSeconds() or len(newSeconds) > __class__.maximumNumberOfSeconds():
return False
oldSeconds = {id(x): x for x in self._seconds}
self._seconds.clear()
for aNewSecond in newSeconds:
self._seconds.append(aNewSecond)
if id(aNewSecond) in oldSeconds:
del oldSeconds[id(aNewSecond)]
else:
aNewSecond.addFirst(self)
for anOldSecond in oldSeconds.values():
anOldSecond.removeFirst(self)
return True
def addSecondAt(self, aSecond, index):
if not self.addSecond(aSecond):
return False
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def addOrMoveSecondAt(self, aSecond, index):
if not any(x is aSecond for x in self._seconds):
return self.addSecondAt(aSecond, index)
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def delete(self):
copyOfSeconds = tuple(self._seconds)
self._seconds.clear()
for aSecond in copyOfSeconds:
aSecond.removeFirst(self)
def setSecond(self, aSecond):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self, *allSeconds):
self._seconds = []
if not self.setSeconds(*allSeconds):
raise RuntimeError("Unable to create First, must have at least 1 seconds. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
def getSecond(self, index):
return self._seconds[index]
def getSeconds(self):
return tuple(self._seconds)
def numberOfSeconds(self):
return len(self._seconds)
def hasSeconds(self):
return len(self._seconds) > 0
def indexOfSecond(self, aSecond):
return next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
def isNumberOfSecondsValid(self):
return self.numberOfSeconds() >= __class__.minimumNumberOfSeconds()
@staticmethod
def minimumNumberOfSeconds():
return 1
def addSecond(self, aSecond):
if any(x is aSecond for x in self._seconds):
return False
self._seconds.append(aSecond)
if aSecond.indexOfFirst(self) == -1 and not aSecond.addFirst(self):
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
return False
return True
def removeSecond(self, aSecond):
oldIndex = next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
if oldIndex == -1:
return False
if self.numberOfSeconds() <= __class__.minimumNumberOfSeconds():
return False
del self._seconds[oldIndex]
if aSecond.indexOfFirst(self) != -1 and not aSecond.removeFirst(self):
self._seconds.insert(oldIndex, aSecond)
return False
return True
def setSeconds(self, *newSeconds):
if len({id(x) for x in newSeconds}) != len(newSeconds) or len(newSeconds) < __class__.minimumNumberOfSeconds():
return False
oldSeconds = {id(x): x for x in self._seconds}
self._seconds.clear()
for aNewSecond in newSeconds:
self._seconds.append(aNewSecond)
if id(aNewSecond) in oldSeconds:
del oldSeconds[id(aNewSecond)]
else:
aNewSecond.addFirst(self)
for anOldSecond in oldSeconds.values():
anOldSecond.removeFirst(self)
return True
def addSecondAt(self, aSecond, index):
if not self.addSecond(aSecond):
return False
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def addOrMoveSecondAt(self, aSecond, index):
if not any(x is aSecond for x in self._seconds):
return self.addSecondAt(aSecond, index)
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def delete(self):
copyOfSeconds = tuple(self._seconds)
self._seconds.clear()
for aSecond in copyOfSeconds:
aSecond.removeFirst(self)
def setSecond(self, aSecond):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self, *allSeconds):
self._seconds = []
if not self.setSeconds(*allSeconds):
raise RuntimeError("Unable to create First, must have 5 seconds. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
def getSecond(self, index):
return self._seconds[index]
def getSeconds(self):
return tuple(self._seconds)
def numberOfSeconds(self):
return len(self._seconds)
def hasSeconds(self):
return len(self._seconds) > 0
def indexOfSecond(self, aSecond):
return next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
def isNumberOfSecondsValid(self):
return self.numberOfSeconds() >= __class__.minimumNumberOfSeconds() and self.numberOfSeconds() <= __class__.maximumNumberOfSeconds()
@staticmethod
def requiredNumberOfSeconds():
return 5
@staticmethod
def minimumNumberOfSeconds():
return 5
@staticmethod
def maximumNumberOfSeconds():
return 5
def addSecond(self, aSecond):
if any(x is aSecond for x in self._seconds):
return False
if self.numberOfSeconds() >= __class__.maximumNumberOfSeconds():
return False
self._seconds.append(aSecond)
if aSecond.indexOfFirst(self) == -1 and not aSecond.addFirst(self):
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
return False
return True
def removeSecond(self, aSecond):
oldIndex = next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
if oldIndex == -1:
return False
if self.numberOfSeconds() <= __class__.minimumNumberOfSeconds():
return False
del self._seconds[oldIndex]
if aSecond.indexOfFirst(self) != -1 and not aSecond.removeFirst(self):
self._seconds.insert(oldIndex, aSecond)
return False
return True
def setSeconds(self, *newSeconds):
if len({id(x) for x in newSeconds}) != len(newSeconds) or len(newSeconds) < __class__.minimumNumberOfSeconds() or len(newSeconds) > __class__.maximumNumberOfSeconds():
return False
oldSeconds = {id(x): x for x in self._seconds}
self._seconds.clear()
for aNewSecond in newSeconds:
self._seconds.append(aNewSecond)
if id(aNewSecond) in oldSeconds:
del oldSeconds[id(aNewSecond)]
else:
aNewSecond.addFirst(self)
for anOldSecond in oldSeconds.values():
anOldSecond.removeFirst(self)
return True
def delete(self):
copyOfSeconds = tuple(self._seconds)
self._seconds.clear()
for aSecond in copyOfSeconds:
aSecond.removeFirst(self)
def setSecond(self, aSecond):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self):
self._seconds = []
def getSecond(self, index):
return self._seconds[index]
def getSeconds(self):
return tuple(self._seconds)
def numberOfSeconds(self):
return len(self._seconds)
def hasSeconds(self):
return len(self._seconds) > 0
def indexOfSecond(self, aSecond):
return next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
@staticmethod
def minimumNumberOfSeconds():
return 0
@staticmethod
def maximumNumberOfSeconds():
return 5
def addSecond(self, aSecond):
if any(x is aSecond for x in self._seconds):
return False
if self.numberOfSeconds() >= __class__.maximumNumberOfSeconds():
return False
self._seconds.append(aSecond)
if aSecond.indexOfFirst(self) == -1 and not aSecond.addFirst(self):
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
return False
return True
def removeSecond(self, aSecond):
oldIndex = next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
if oldIndex == -1:
return False
del self._seconds[oldIndex]
if aSecond.indexOfFirst(self) != -1 and not aSecond.removeFirst(self):
self._seconds.insert(oldIndex, aSecond)
return False
return True
def setSeconds(self, *newSeconds):
if len({id(x) for x in newSeconds}) != len(newSeconds) or len(newSeconds) > __class__.maximumNumberOfSeconds():
return False
oldSeconds = {id(x): x for x in self._seconds}
self._seconds.clear()
for aNewSecond in newSeconds:
self._seconds.append(aNewSecond)
if id(aNewSecond) in oldSeconds:
del oldSeconds[id(aNewSecond)]
else:
aNewSecond.addFirst(self)
for anOldSecond in oldSeconds.values():
anOldSecond.removeFirst(self)
return True
def addSecondAt(self, aSecond, index):
if not self.addSecond(aSecond):
return False
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def addOrMoveSecondAt(self, aSecond, index):
if not any(x is aSecond for x in self._seconds):
return self.addSecondAt(aSecond, index)
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def delete(self):
copyOfSeconds = tuple(self._seconds)
self._seconds.clear()
for aSecond in copyOfSeconds:
aSecond.removeFirst(self)
def setSecond(self, aSecond):
return False
def isNumberOfSecondsValid(self):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self):
self._seconds = []
def getSecond(self, index):
return self._seconds[index]
def getSeconds(self):
return tuple(self._seconds)
def numberOfSeconds(self):
return len(self._seconds)
def hasSeconds(self):
return len(self._seconds) > 0
def indexOfSecond(self, aSecond):
return next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
@staticmethod
def minimumNumberOfSeconds():
return 0
def addSecond(self, aSecond):
if any(x is aSecond for x in self._seconds):
return False
self._seconds.append(aSecond)
if aSecond.indexOfFirst(self) == -1 and not aSecond.addFirst(self):
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
return False
return True
def removeSecond(self, aSecond):
oldIndex = next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
if oldIndex == -1:
return False
del self._seconds[oldIndex]
if aSecond.indexOfFirst(self) != -1 and not aSecond.removeFirst(self):
self._seconds.insert(oldIndex, aSecond)
return False
return True
def addSecondAt(self, aSecond, index):
if not self.addSecond(aSecond):
return False
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def addOrMoveSecondAt(self, aSecond, index):
if not any(x is aSecond for x in self._seconds):
return self.addSecondAt(aSecond, index)
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def delete(self):
copyOfSeconds = tuple(self._seconds)
self._seconds.clear()
for aSecond in copyOfSeconds:
aSecond.removeFirst(self)
def setSecond(self, aSecond):
return False
def setSeconds(self, *newSeconds):
return False
def isNumberOfSecondsValid(self):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self):
self._second = None
from Second import Second
self._second = Second.alternateConstructor(self)
@classmethod
def alternateConstructor(cls, aSecond):
self = cls.__new__(cls)
__class__._alternateInit(self, aSecond)
return self
def _alternateInit(self, aSecond):
self._second = None
if aSecond is None or aSecond.getFirst() is not None:
raise RuntimeError("Unable to create First due to aSecond. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
self._second = aSecond
def getSecond(self):
return self._second
def delete(self):
existingSecond = self._second
self._second = None
if existingSecond is not None:
existingSecond.delete()
def addSecond(self, aSecond):
return False
def getSeconds(self):
return None
def setSecond(self, aSecond):
return False
def setSeconds(self, *newSeconds):
return False
def numberOfSeconds(self):
return 0
def hasSeconds(self):
return False
def indexOfSecond(self, second):
return 0
def isNumberOfSecondsValid(self):
return False
def removeSecond(self, second):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self):
self._seconds = []
def getSecond(self, index):
return self._seconds[index]
def getSeconds(self):
return tuple(self._seconds)
def numberOfSeconds(self):
return len(self._seconds)
def hasSeconds(self):
return len(self._seconds) > 0
def indexOfSecond(self, aSecond):
return next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
def isNumberOfSecondsValid(self):
return self.numberOfSeconds() >= __class__.minimumNumberOfSeconds() and self.numberOfSeconds() <= __class__.maximumNumberOfSeconds()
@staticmethod
def requiredNumberOfSeconds():
return 5
@staticmethod
def minimumNumberOfSeconds():
return 5
@staticmethod
def maximumNumberOfSeconds():
return 5
def addSecond(self, aSecond):
if any(x is aSecond for x in self._seconds):
return False
if self.numberOfSeconds() >= __class__.maximumNumberOfSeconds():
return False
self._seconds.append(aSecond)
if aSecond.indexOfFirst(self) == -1 and not aSecond.addFirst(self):
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
return False
return True
def removeSecond(self, aSecond):
oldIndex = next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
if oldIndex == -1:
return False
if self.numberOfSeconds() <= __class__.minimumNumberOfSeconds():
return False
del self._seconds[oldIndex]
if aSecond.indexOfFirst(self) != -1 and not aSecond.removeFirst(self):
self._seconds.insert(oldIndex, aSecond)
return False
return True
def setSeconds(self, *newSeconds):
if len({id(x) for x in newSeconds}) != len(newSeconds) or len(newSeconds) < __class__.minimumNumberOfSeconds() or len(newSeconds) > __class__.maximumNumberOfSeconds():
return False
oldSeconds = {id(x): x for x in self._seconds}
self._seconds.clear()
for aNewSecond in newSeconds:
self._seconds.append(aNewSecond)
if id(aNewSecond) in oldSeconds:
del oldSeconds[id(aNewSecond)]
else:
aNewSecond.addFirst(self)
for anOldSecond in oldSeconds.values():
anOldSecond.removeFirst(self)
return True
def delete(self):
from Second import Second
copyOfSeconds = tuple(self._seconds)
self._seconds.clear()
for aSecond in copyOfSeconds:
if aSecond.numberOfFirsts() <= Second.minimumNumberOfFirsts():
aSecond.delete()
else:
aSecond.removeFirst(self)
def setSecond(self, aSecond):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self):
self._seconds = []
def getSecond(self, index):
return self._seconds[index]
def getSeconds(self):
return tuple(self._seconds)
def numberOfSeconds(self):
return len(self._seconds)
def hasSeconds(self):
return len(self._seconds) > 0
def indexOfSecond(self, aSecond):
return next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
def isNumberOfSecondsValid(self):
return self.numberOfSeconds() >= __class__.minimumNumberOfSeconds() and self.numberOfSeconds() <= __class__.maximumNumberOfSeconds()
@staticmethod
def minimumNumberOfSeconds():
return 2
@staticmethod
def maximumNumberOfSeconds():
return 4
def addSecond(self, aSecond):
if any(x is aSecond for x in self._seconds):
return False
if self.numberOfSeconds() >= __class__.maximumNumberOfSeconds():
return False
self._seconds.append(aSecond)
if aSecond.indexOfFirst(self) == -1 and not aSecond.addFirst(self):
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
return False
return True
def removeSecond(self, aSecond):
oldIndex = next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
if oldIndex == -1:
return False
if self.numberOfSeconds() <= __class__.minimumNumberOfSeconds():
return False
del self._seconds[oldIndex]
if aSecond.indexOfFirst(self) != -1 and not aSecond.removeFirst(self):
self._seconds.insert(oldIndex, aSecond)
return False
return True
def setSeconds(self, *newSeconds):
if len({id(x) for x in newSeconds}) != len(newSeconds) or len(newSeconds) < __class__.minimumNumberOfSeconds() or len(newSeconds) > __class__.maximumNumberOfSeconds():
return False
oldSeconds = {id(x): x for x in self._seconds}
self._seconds.clear()
for aNewSecond in newSeconds:
self._seconds.append(aNewSecond)
if id(aNewSecond) in oldSeconds:
del oldSeconds[id(aNewSecond)]
else:
aNewSecond.addFirst(self)
for anOldSecond in oldSeconds.values():
anOldSecond.removeFirst(self)
return True
def addSecondAt(self, aSecond, index):
if not self.addSecond(aSecond):
return False
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def addOrMoveSecondAt(self, aSecond, index):
if not any(x is aSecond for x in self._seconds):
return self.addSecondAt(aSecond, index)
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def delete(self):
from Second import Second
copyOfSeconds = tuple(self._seconds)
self._seconds.clear()
for aSecond in copyOfSeconds:
if aSecond.numberOfFirsts() <= Second.minimumNumberOfFirsts():
aSecond.delete()
else:
aSecond.removeFirst(self)
def setSecond(self, aSecond):
return False
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.38.0.8942.247e17422 modeling language!
from I import I
class First(I):
def __init__(self):
self._seconds = []
def getSecond(self, index):
return self._seconds[index]
def getSeconds(self):
return tuple(self._seconds)
def numberOfSeconds(self):
return len(self._seconds)
def hasSeconds(self):
return len(self._seconds) > 0
def indexOfSecond(self, aSecond):
return next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
def isNumberOfSecondsValid(self):
return self.numberOfSeconds() >= __class__.minimumNumberOfSeconds() and self.numberOfSeconds() <= __class__.maximumNumberOfSeconds()
@staticmethod
def minimumNumberOfSeconds():
return 1
@staticmethod
def maximumNumberOfSeconds():
return 4
def addSecond1(self):
if self.numberOfSeconds() >= self.maximumNumberOfSeconds():
return None
from Second import Second
return Second(self)
def addSecond2(self, aSecond):
if any(x is aSecond for x in self._seconds):
return False
if self.numberOfSeconds() >= self.maximumNumberOfSeconds():
return False
existingFirst = aSecond.getFirst()
isNewFirst = existingFirst is not None and existingFirst is not self
if isNewFirst and existingFirst.numberOfSeconds() <= self.minimumNumberOfSeconds():
return False
if isNewFirst:
if not aSecond.setFirst(self):
return False
else:
self._seconds.append(aSecond)
return True
def addSecond(self, *args, **kwargs):
from Second import Second
bound = __class__._bindArguments(("aSecond",), False, args, kwargs)
if bound is not None and (bound[0] is None or isinstance(bound[0], Second)):
return __class__.addSecond2(self, *bound)
bound = __class__._bindArguments((), False, args, kwargs)
if bound is not None:
return __class__.addSecond1(self, *bound)
raise TypeError("No method matches provided parameters")
def removeSecond(self, aSecond):
if aSecond.getFirst() is self:
return False
if self.numberOfSeconds() <= self.minimumNumberOfSeconds():
return False
index = next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)
if index >= 0:
del self._seconds[index]
return True
def addSecondAt(self, aSecond, index):
if not self.addSecond2(aSecond):
return False
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def addOrMoveSecondAt(self, aSecond, index):
if not any(x is aSecond for x in self._seconds):
return self.addSecondAt(aSecond, index)
if index < 0:
index = 0
if index > self.numberOfSeconds():
index = self.numberOfSeconds() - 1
del self._seconds[next((i for i, x in enumerate(self._seconds) if x is aSecond), -1)]
self._seconds.insert(index, aSecond)
return True
def delete(self):
for i in range(len(self._seconds), 0, -1):
aSecond = self._seconds[i - 1]
aSecond.delete()
def setSecond(self, aSecond):
return False
def setSeconds(self, *newSeconds):
return False
@staticmethod
def _bindArguments(names, varargs, args, kwargs):
if len(args) > len(names) and not varargs:
return None
bound = list(args[:len(names)])
for name in names[len(bound):]:
if name not in kwargs:
return None
bound.append(kwargs[name])
if len(kwargs) != len(names) - min(len(args), len(names)):
return None
if varargs:
bound.append(args[len(names):])
return bound