Search in sources :

Example 1 with FieldSetter

use of org.kohsuke.args4j.spi.FieldSetter in project newts by OpenNMS.

the class MergeSort method createCmdLineParser.

private CmdLineParser createCmdLineParser() {
    return new CmdLineParser(this) {

        @SuppressWarnings("rawtypes")
        @Override
        public void addArgument(final Setter setter, Argument a) {
            Setter newSetter = setter;
            if (setter instanceof MethodSetter) {
                newSetter = new Setter() {

                    @SuppressWarnings("unchecked")
                    @Override
                    public void addValue(Object value) throws CmdLineException {
                        setter.addValue(value);
                    }

                    @Override
                    public Class getType() {
                        return setter.getType();
                    }

                    @Override
                    public boolean isMultiValued() {
                        return false;
                    }

                    @Override
                    public FieldSetter asFieldSetter() {
                        return setter.asFieldSetter();
                    }

                    @Override
                    public AnnotatedElement asAnnotatedElement() {
                        return setter.asAnnotatedElement();
                    }
                };
            }
            super.addArgument(newSetter, a);
        }
    };
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) Argument(org.kohsuke.args4j.Argument) MethodSetter(org.kohsuke.args4j.spi.MethodSetter) FieldSetter(org.kohsuke.args4j.spi.FieldSetter) MethodSetter(org.kohsuke.args4j.spi.MethodSetter) Setter(org.kohsuke.args4j.spi.Setter) FieldSetter(org.kohsuke.args4j.spi.FieldSetter) AnnotatedElement(java.lang.reflect.AnnotatedElement) CmdLineException(org.kohsuke.args4j.CmdLineException)

Aggregations

AnnotatedElement (java.lang.reflect.AnnotatedElement)1 Argument (org.kohsuke.args4j.Argument)1 CmdLineException (org.kohsuke.args4j.CmdLineException)1 CmdLineParser (org.kohsuke.args4j.CmdLineParser)1 FieldSetter (org.kohsuke.args4j.spi.FieldSetter)1 MethodSetter (org.kohsuke.args4j.spi.MethodSetter)1 Setter (org.kohsuke.args4j.spi.Setter)1