def _HandleImports(self, element):
    """Handles imports for the specified element.

    Args:
      element: (Property|Parameter) The property we want to set the import for.
    """
    # Get the parent of this Property/Parameter.
    parent = element.schema
    if self._InnerModelClassesSupported():
      # If inner classes are supported find the top level parent to set
      # imports for.
      while parent.parent:
        parent = parent.parent
    import_manager = JavaImportManager.GetCachedImportManager(parent)

    # For collections, we have to get the imports for the first non-collection
    # up the base_type chain.
    data_type = element.data_type
    json_type = data_type.json_type
    while json_type == 'array' or json_type == 'map':
      data_type = data_type._base_type  # pylint: disable=protected-access
      json_type = data_type.json_type
    json_format = data_type.values.get('format')

    type_format_to_datatype_and_imports = self.language_model.type_map
    datatype_and_imports = (
        type_format_to_datatype_and_imports.get((json_type, json_format)))
    if datatype_and_imports:
      import_definition = datatype_and_imports[1]
      # Import all required imports.
      for required_import in import_definition.imports:
        import_manager.AddImport(required_import)
      # Set all template values, if specified.
      for template_value in import_definition.template_values:
        element.SetTemplateValue(template_value, True)
dataset/ETHPy150Open google/apis-client-generator/src/googleapis/codegen/java_generator.py/BaseJavaGenerator._HandleImports/original