/** * Creates an {@link OptionHandler} that handles the given {@link Option} annotation * and the {@link Setter} instance. */ @SuppressWarnings("unchecked") protected OptionHandler createOptionHandler(CmdLineParser parser, OptionDef o, Setter setter) { checkNonNull(o, "CmdLineParser"); checkNonNull(o, "OptionDef"); checkNonNull(setter, "Setter"); Class<? extends OptionHandler> h = o.handler(); if(h==OptionHandler.class) { // infer the type Class<?> t = setter.getType(); // enum is the special case if(Enum.class.isAssignableFrom(t)) return new EnumOptionHandler(parser,o,setter,t); OptionHandlerFactory factory = handlers.get(t); if (factory==null) throw new IllegalAnnotationError(Messages.UNKNOWN_HANDLER.format(t)); return factory.getHandler(parser, o, setter); } else { // explicit handler specified return new DefaultConstructorHandlerFactory(h).getHandler(parser, o, setter); } }
/** * Creates an {@link OptionHandler} that handles the given {@link Option} annotation * and the {@link Setter} instance. */ @SuppressWarnings("unchecked") protected OptionHandler createOptionHandler(CmdLineParser parser, OptionDef o, Setter setter) { checkNonNull(o, "CmdLineParser"); checkNonNull(o, "OptionDef"); checkNonNull(setter, "Setter"); Class<? extends OptionHandler> h = o.handler(); if(h==OptionHandler.class) { // infer the type Class<?> t = setter.getType(); // enum is the special case if(Enum.class.isAssignableFrom(t)) return new EnumOptionHandler(parser,o,setter,t); OptionHandlerFactory factory = handlers.get(t); if (factory==null) throw new IllegalAnnotationError(Messages.UNKNOWN_HANDLER.format(t)); return factory.getHandler(parser, o, setter); } else { // explicit handler specified return new DefaultConstructorHandlerFactory(h).getHandler(parser, o, setter); } }
private boolean isHandlerSpecified(final OptionDef option) { return option.handler() != OptionHandler.class; }
private boolean isHandlerSpecified(final OptionDef option) { return option.handler() != OptionHandler.class; }
public MyOptionDef(OptionDef o) { super(o.usage(), o.metaVar(), o.required(), o.handler(), o .isMultiValued()); }
/** * Creates an {@link OptionHandler} that handles the given {@link Option} annotation * and the {@link Setter} instance. */ @SuppressWarnings("unchecked") protected OptionHandler createOptionHandler(CmdLineParser parser, OptionDef o, Setter setter) { checkNonNull(o, "CmdLineParser"); checkNonNull(o, "OptionDef"); checkNonNull(setter, "Setter"); Class<? extends OptionHandler> h = o.handler(); if(h==OptionHandler.class) { // infer the type Class<?> t = setter.getType(); // enum is the special case if(Enum.class.isAssignableFrom(t)) return new EnumOptionHandler(parser,o,setter,t); OptionHandlerFactory factory = handlers.get(t); if (factory==null) throw new IllegalAnnotationError(Messages.UNKNOWN_HANDLER.format(t)); return factory.getHandler(parser, o, setter); } else { // explicit handler specified return new DefaultConstructorHandlerFactory(h).getHandler(parser, o, setter); } }
/** * Creates an {@link OptionHandler} that handles the given {@link Option} annotation * and the {@link Setter} instance. */ @SuppressWarnings("unchecked") protected OptionHandler createOptionHandler(CmdLineParser parser, OptionDef o, Setter setter) { checkNonNull(o, "CmdLineParser"); checkNonNull(o, "OptionDef"); checkNonNull(setter, "Setter"); Class<? extends OptionHandler> h = o.handler(); if(h==OptionHandler.class) { // infer the type Class<?> t = setter.getType(); // enum is the special case if(Enum.class.isAssignableFrom(t)) return new EnumOptionHandler(parser,o,setter,t); OptionHandlerFactory factory = handlers.get(t); if (factory==null) throw new IllegalAnnotationError(Messages.UNKNOWN_HANDLER.format(t)); return factory.getHandler(parser, o, setter); } else { // explicit handler specified return new DefaultConstructorHandlerFactory(h).getHandler(parser, o, setter); } }