Package org.kohsuke.stapler

Examples of org.kohsuke.stapler.ClassDescriptor


        }

        return new NamedArgsAndClosure(singleParam(d, arg), null);
    }
    private static Map<String,Object> singleParam(StepDescriptor d, Object arg) {
        String[] names = new ClassDescriptor(d.clazz).loadConstructorParamNames();
        if (names.length == 1) {
            return Collections.singletonMap(names[0], arg);
        } else {
            throw new IllegalArgumentException("Expected named arguments but got " + arg);
        }
View Full Code Here


        }
        throw new UnsupportedOperationException("Unknown step " + clazz);
    }

    private static boolean isDefaultKey(Step step, String key) {
        String[] names = new ClassDescriptor(step.getClass()).loadConstructorParamNames();
        return names.length == 1 && key.equals(names[0]);
    }
View Full Code Here

     * or it may be omitted if the argument is declared to take a concrete type;
     * or {@link Class#getSimpleName} may be used in case the argument type is {@link Describable}
     * and only one subtype is registered (as a {@link Descriptor}) with that simple name.
     */
    public static <T> T instantiate(Class<? extends T> clazz, Map<String,?> arguments) throws Exception {
        ClassDescriptor d = new ClassDescriptor(clazz);
        String[] names = d.loadConstructorParamNames();
        Constructor<T> c = findConstructor(clazz, names.length);
        Object[] args = buildArguments(clazz, arguments, c.getGenericParameterTypes(), names, true);
        T o = c.newInstance(args);
        injectSetters(o, arguments);
        return o;
View Full Code Here

     * @throws UnsupportedOperationException if the class does not follow the expected structure
     */
    public static Map<String,Object> uninstantiate(Object o) throws UnsupportedOperationException {
        Class<?> clazz = o.getClass();
        Map<String, Object> r = new TreeMap<String, Object>();
        ClassDescriptor d = new ClassDescriptor(clazz);
        String[] names;
        try {
            names = d.loadConstructorParamNames();
        } catch (NoStaplerConstructorException x) {
            throw new UnsupportedOperationException(x);
        }
        for (String name : names) {
            inspect(r, o, clazz, name);
View Full Code Here

TOP

Related Classes of org.kohsuke.stapler.ClassDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.