Class 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
    • 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.