Package org.kohsuke.args4j

## Class OptionHandlerRegistry

- java.lang.Object
- - org.kohsuke.args4j.OptionHandlerRegistry

    public class OptionHandlerRegistry
    extends java.lang.Object

Manages the registration of option handlers. This is good for registering custom handlers for specific parameter classes not yet implemented. The registry is a singleton that can be retrieved with the `getRegistry()` call.

Author:
  Stephan Fuhrmann

### Nested Class Summary

Nested Classes
`static interface` `OptionHandlerRegistry.OptionHandlerFactory` Provide custom logic for creating `OptionHandler` implementation.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected OptionHandler` `createOptionHandler​(CmdLineParser parser, OptionDef o, Setter setter)` Creates an `OptionHandler` that handles the given `Option` annotation and the `Setter` instance.
`static OptionHandlerRegistry` `getRegistry()` Gets the option handler registry singleton instance.
`void` `registerHandler​(java.lang.Class valueType, java.lang.Class<? extends OptionHandler> handlerClass)` Registers a user-defined `OptionHandler` class with args4j.
`void` `registerHandler​(java.lang.Class valueType, OptionHandlerRegistry.OptionHandlerFactory factory)` Registers a user-defined `OptionHandler` class with args4j.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getRegistry

    public static OptionHandlerRegistry getRegistry()

Gets the option handler registry singleton instance.

Returns:
  a shared instance of the registry.

#### registerHandler

    public void registerHandler​(java.lang.Class valueType,
                                java.lang.Class<? extends OptionHandler> handlerClass)

Registers a user-defined `OptionHandler` class with args4j.

This method allows users to extend the behavior of args4j by writing their own `OptionHandler` implementation.

Parameters:
  `valueType` - The specified handler is used when the field/method annotated by `Option` is of this type.
  `handlerClass` - This class must have the constructor that has the same signature as `OptionHandler(CmdLineParser, OptionDef, Setter)`
Throws:
  `java.lang.NullPointerException` - if `valueType` or `handlerClass` is `null`.
  `java.lang.IllegalArgumentException` - if `handlerClass` is not a subtype of `OptionHandler`.

#### registerHandler

    public void registerHandler​(java.lang.Class valueType,
                                OptionHandlerRegistry.OptionHandlerFactory factory)

Registers a user-defined `OptionHandler` class with args4j.

This method allows users to extend the behavior of args4j by writing their own `OptionHandler` implementation.

Parameters:
  `valueType` - The specified handler is used when the field/method annotated by `Option` is of this type.
  `factory` - Factory to instantiate handler upon request.
Throws:
  `java.lang.NullPointerException` - if `valueType` or `factory` is `null`.

#### createOptionHandler

    protected OptionHandler createOptionHandler​(CmdLineParser parser,
                                                OptionDef o,
                                                Setter setter)

Creates an `OptionHandler` that handles the given `Option` annotation and the `Setter` instance.