CommandLine.IFactory (picocli 3.9.6 API)
Date: 2019-04-06

picocli

## Interface CommandLine.IFactory

- Enclosing class:
    CommandLine

      public static interface CommandLine.IFactory

  Factory for instantiating classes that are registered declaratively with annotation attributes, like `CommandLine.Command.subcommands()`, `CommandLine.Option.converter()`, `CommandLine.Parameters.converter()` and `CommandLine.Command.versionProvider()`.

  The default factory implementation simply creates a new instance of the specified class when `create(Class)` is invoked.

  You may provide a custom implementation of this interface. For example, a custom factory implementation could delegate to a dependency injection container that provides the requested instance.

  Since:
    2.2
  See Also:
    `CommandLine.CommandLine(Object, IFactory)`, `CommandLine.call(Class, IFactory, PrintStream, PrintStream, Help.Ansi, String...)`, `CommandLine.run(Class, IFactory, PrintStream, PrintStream, Help.Ansi, String...)`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `<K> K` | `create(java.lang.Class<K> cls)` Returns an instance of the specified class.

- - ### Method Detail

    - #### create

          <K> K create(java.lang.Class<K> cls)
                throws java.lang.Exception

      Returns an instance of the specified class.
      Type Parameters:
        `K` - the type of the object to return
      Parameters:
        `cls` - the class of the object to return
      Returns:
        the instance
      Throws:
        `java.lang.Exception` - an exception detailing what went wrong when creating or obtaining the instance