'Upgrades this object to the type specified.
AFF4 Objects can be upgraded on the fly to other type - As long as the new
type is derived from the current type. This feature allows creation of
placeholder objects which can later be upgraded to the fully featured
object.
Note: It is not allowed to downgrade an object if that would result in a
loss of information (since the new object has a smaller schema). This method
tries to store the new object with its new attributes and will fail if any
attributes can not be mapped.
Args:
aff4_class: A string representing the new class.
Returns:
an instance of the new class with all the same attributes as this current
object.
Raises:
RuntimeError: When the object to upgrade is locked.
AttributeError: When the new object can not accept some of the old
attributes.
InstantiationError: When we cannot instantiate the object type class.'

def Upgrade(self, aff4_class):

    aff4_class = _ValidateAFF4Type(aff4_class)
    if (self.__class__ == aff4_class):
        return self
    if (not isinstance(aff4_class, type)):
        raise InstantiationError(('aff4_class=%s    must    be    a    type' % aff4_class))
    if (not issubclass(aff4_class, AFF4Object)):
        raise InstantiationError(('aff4_class=%s    must    be    a    subclass    of    AFF4Object.' % aff4_class))
    if isinstance(self, aff4_class):
        return self
    result = aff4_class(self.urn, mode=self.mode, clone=self, parent=self.parent, token=self.token, age=self.age_policy, object_exists=self.object_exists, follow_symlinks=self.follow_symlinks, aff4_type=self.aff4_type, mutation_pool=self.mutation_pool, transaction=self.transaction)
    result.symlink_urn = self.urn
    result.Initialize()
    return result
