java.lang.Object
dk.mada.jaxrs.generator.mpclient.imports.Imports

public final class Imports extends Object
Keeps track of imports for a single template, taking generator options into consideration.
  • Method Details

    • get

      public SortedSet<String> get()
      Returns a sorted set of classes to import.
      Returns:
      a sorted set of classes to import
    • newApi

      public static Imports newApi(GeneratorOpts opts)
      Creates a new instance for API files. Adds common imports need by all APIs.
      Parameters:
      opts - the generator options
      Returns:
      a new imports instance loaded with enumeration imports
    • newDto

      public static Imports newDto(GeneratorOpts opts, boolean hasParams)
      Creates a new instance for DTO files. Adds common imports need by all DTOs.
      Parameters:
      opts - the generator options
      hasParams - true if the DTO has any properties
      Returns:
      a new imports instance loaded with enumeration imports
    • newEnum

      public static Imports newEnum(GeneratorOpts opts, boolean includeObjects)
      Creates a new instance for enumeration types.
      Parameters:
      opts - the generator options
      includeObjects - flag to include Objects
      Returns:
      a new imports instance loaded with enumeration imports
    • newInterface

      public static Imports newInterface(GeneratorOpts opts)
      Adds imports needed for interface templates.
      Parameters:
      opts - the generator options
      Returns:
      a new imports instance
    • newExtras

      public static Imports newExtras(GeneratorOpts opts, ExtraTemplate tmpl)
      Adds imports needed for extra templates.
      Parameters:
      opts - the generator options
      tmpl - the template to add imports for
      Returns:
      a new imports instance
    • addEnumImports

      public Imports addEnumImports(boolean includeTypeAdapter, boolean includeObjects)
      Adds imports needed for rendering an enumeration.
      Parameters:
      includeTypeAdapter - flag to include typeAdaptor
      includeObjects - flag to include Objects
      Returns:
      this
    • addPropertyImports

      public void addPropertyImports(Collection<Property> properties)
      Add imports for the types referenced by properties.
      Parameters:
      properties - the properties to add imports for
    • add

      public Imports add(TypedImport... classes)
      Adds typed imports.
      Parameters:
      classes - the classes to add imports for
      Returns:
      the imports instance
    • add

      public Imports add(Collection<TypedImport> classes)
      Adds typed imports.
      Parameters:
      classes - the classes to add imports for
      Returns:
      the imports instance
    • add

      public Imports add(boolean active, TypedImport... classes)
      Optionally adds typed imports.
      Parameters:
      active - option to control if the classes should be added
      classes - the classes to add imports for
      Returns:
      the imports instance
    • add

      public Imports add(Reference typeRef)
      Adds import for a reference - the type it references.
      Parameters:
      typeRef - the type reference
      Returns:
      the imports instance
    • add

      public Imports add(Type type)
      Adds imports for a type. If the type is externally mapped, just adds an import of the class. Otherwise adds imports for dependency and container-wrapper classes as well.
      Parameters:
      type - the type to add imports for
      Returns:
      the imports instance
    • addMicroProfileSchema

      public Imports addMicroProfileSchema()
      Adds import for Schema.
      Returns:
      the imports instance
    • trimContainerImplementations

      public void trimContainerImplementations()
      Remove container implementations (e.g. ArrayList) from imports for use in Api files. Maybe need a better way to handle this.