<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def InitFromAff4Object(self, file_obj, stat_entry=None, hash_entry=None, with_details=False):
 """Initializes the current instance from an Aff4Stream. Args: file_obj: An Aff4Stream representing a file. stat_entry: An optional stat entry object to be used. If none is provided, the one stored in the AFF4 data store is used. hash_entry: An optional hash entry object to be used. If none is provided, the one stored in the AFF4 data store is used. with_details: True if all details of the Aff4Object should be included, false otherwise. Returns: A reference to the current instance. """

    self.name = file_obj.urn.Basename()
    self.path = "/".join(file_obj.urn.Path().split("/")[2:])
    self.is_directory = "Container" in file_obj.behaviours

    self.stat = stat_entry or file_obj.Get(file_obj.Schema.STAT)
    self.hash = hash_entry or file_obj.Get(file_obj.Schema.HASH, None)

    if not self.is_directory:
      try:
        self.last_collected = file_obj.GetContentAge()
      except AttributeError:
        # Defensive approach - in case file-like object doesn't have
        # GetContentAge defined.
        logging.debug("File-like object %s doesn't have GetContentAge defined.",
                      file_obj.__class__.__name__)

      if self.last_collected:
        self.last_collected_size = file_obj.Get(file_obj.Schema.SIZE)

    type_obj = file_obj.Get(file_obj.Schema.TYPE)
    if type_obj is not None:
      self.age = type_obj.age

    if with_details:
      self.details = ApiAff4ObjectRepresentation().InitFromAff4Object(file_obj)

    return self