Interface Importer<O extends JavaSource<O>>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Import addImport​(java.lang.Class<?> type)
      Add an import for the given Class type.
      Import addImport​(java.lang.String className)
      Add an import by qualified class name.
      Import addImport​(Import imprt)
      Add an import for the given Import type.
      Import addImport​(Type<?> type)
      Ensures the type passed as argument is included in the list of imports for this java source.
      <T extends JavaType<?>>
      Import
      addImport​(T type)
      Add an import for the given JavaType type.
      Import getImport​(java.lang.Class<?> type)
      Get the Import for the given Class type, if it exists; otherwise, return null;
      Import getImport​(java.lang.String literalValue)
      Get the Import for the given fully-qualified class name, if it exists; otherwise, return null;
      Import getImport​(Import imprt)
      Get the Import of the given Import type, if it exists; otherwise, return null;
      <T extends JavaType<?>>
      Import
      getImport​(T type)
      Get the Import for the given Importer type, if it exists; otherwise, return null;
      java.util.List<Import> getImports()
      Get an immutable list of all Imports currently imported by this Importer
      boolean hasImport​(java.lang.Class<?> type)
      Return whether or not this Importer has an import for the given Class type.
      boolean hasImport​(java.lang.String type)
      Return whether or not this Importer has an import for the given fully-qualified class name.
      boolean hasImport​(Import imprt)
      Return whether or not this Importer has the given Import type.
      <T extends JavaType<T>>
      boolean
      hasImport​(T type)
      Return whether or not this Importer has an import for the given Importer type.
      O removeImport​(java.lang.Class<?> type)
      Remove any Import for the given Class type, if it exists; otherwise, do nothing;
      O removeImport​(java.lang.String name)
      Remove any Import for the given fully-qualified class name, if it exists; otherwise, do nothing;
      O removeImport​(Import imprt)
      Remove the given Import from this Importer instance, if it exists; otherwise, do nothing;
      <T extends JavaType<?>>
      O
      removeImport​(T type)
      Remove any Import for the given Importer type, if it exists; otherwise, do nothing;
      boolean requiresImport​(java.lang.Class<?> type)
      Return whether or not this Importer would require an import to reference the given Class type.
      boolean requiresImport​(java.lang.String type)
      Return whether or not this Importer would require an import to reference the given fully-qualified class name.
      java.lang.String resolveType​(java.lang.String type)
      Given a simple or qualified type, resolve that type against the available imports and return the referenced type.
    • Method Detail

      • hasImport

        boolean hasImport​(java.lang.Class<?> type)
        Return whether or not this Importer has an import for the given Class type.
      • hasImport

        boolean hasImport​(java.lang.String type)
        Return whether or not this Importer has an import for the given fully-qualified class name.
      • requiresImport

        boolean requiresImport​(java.lang.Class<?> type)
        Return whether or not this Importer would require an import to reference the given Class type.
      • requiresImport

        boolean requiresImport​(java.lang.String type)
        Return whether or not this Importer would require an import to reference the given fully-qualified class name. If the type is generic, the generic parts are also checked in a recursive way.
      • hasImport

        <T extends JavaType<T>> boolean hasImport​(T type)
        Return whether or not this Importer has an import for the given Importer type.
      • hasImport

        boolean hasImport​(Import imprt)
        Return whether or not this Importer has the given Import type.
      • getImport

        Import getImport​(java.lang.String literalValue)
        Get the Import for the given fully-qualified class name, if it exists; otherwise, return null;
      • getImport

        Import getImport​(java.lang.Class<?> type)
        Get the Import for the given Class type, if it exists; otherwise, return null;
      • getImport

        <T extends JavaType<?>> Import getImport​(T type)
        Get the Import for the given Importer type, if it exists; otherwise, return null;
      • getImport

        Import getImport​(Import imprt)
        Get the Import of the given Import type, if it exists; otherwise, return null;
      • getImports

        java.util.List<Import> getImports()
        Get an immutable list of all Imports currently imported by this Importer
      • resolveType

        java.lang.String resolveType​(java.lang.String type)
        Given a simple or qualified type, resolve that type against the available imports and return the referenced type. The resolving processing order is as followed:
        1. If the type is primitive or full qualified, the type is returned as it
        2. Find the type in the imports with the simple name
        3. If only one wildcard import is used, use this import for resolving
        4. Use the available WildcardImportResolver. The first qualified name is used
        5. The current package if defined is used for resolving
        6. The type is returned as it
        If the type is returned as it, maybe parts which can hinder we matching process like generic's are stripped of.
        Parameters:
        type - the type to resolve
        Returns:
        the (resolved) type
      • addImport

        Import addImport​(java.lang.String className)
        Add an import by qualified class name. (E.g: "com.example.Imported") unless it is in the provided 'java.lang.*' package. In the case of a generic type, the classes used are recursively also imported.
      • addImport

        Import addImport​(java.lang.Class<?> type)
        Add an import for the given Class type.
      • addImport

        Import addImport​(Type<?> type)
        Ensures the type passed as argument is included in the list of imports for this java source. The method will also recursively import parameter types. This method is idempotent: if a type has already been imported, no further action will be required. The method returns an Import object which should be used to reference the imported type in the code if the import operation is valid or null if one of the following conditions is met: - This type is the same type as the Class name - This type cannot be added to the import statement because it references a type with the same name but from a different package - This type belongs to the java.lang package
        Parameters:
        type - The Type to be imported.
        Returns:
        The name (simple or fully qualified) that should be used to reference the imported type in the code or null if the import could not be performed due to one of the following conditions is met: - This type is the same type as the Class name - This type cannot be added to the import statement because it references a type with the same name but from a different package - This type belongs to the java.lang package
      • removeImport

        O removeImport​(java.lang.String name)
        Remove any Import for the given fully-qualified class name, if it exists; otherwise, do nothing;
      • removeImport

        O removeImport​(java.lang.Class<?> type)
        Remove any Import for the given Class type, if it exists; otherwise, do nothing;
      • removeImport

        <T extends JavaType<?>> O removeImport​(T type)
        Remove any Import for the given Importer type, if it exists; otherwise, do nothing;
      • removeImport

        O removeImport​(Import imprt)
        Remove the given Import from this Importer instance, if it exists; otherwise, do nothing;