Search in sources :

Example 1 with ModelBinding

use of org.glassfish.api.admin.config.ModelBinding in project Payara by payara.

the class CommandModelImpl method add.

private static void add(Map<String, ParamModel> results, AnnotatedElement e, I18n parentI18n, LocalStringManager localStrings) {
    Param param = e.getAnnotation(Param.class);
    if (param != null) {
        String defaultValue = param.defaultValue();
        ModelBinding mb = e.getAnnotation(ModelBinding.class);
        if (mb != null && defaultValue.isEmpty()) {
            Method m = null;
            try {
                m = mb.type().getMethod(mb.getterMethodName());
            } catch (NoSuchMethodException e1) {
            // ignore.
            }
            if (m != null) {
                Attribute attr = m.getAnnotation(Attribute.class);
                if (attr != null) {
                    defaultValue = attr.defaultValue();
                }
            }
        }
        ParamModel model = new ParamModelImpl(e, defaultValue, parentI18n, localStrings);
        if (!results.containsKey(model.getName())) {
            results.put(model.getName(), model);
        }
    }
}
Also used : ModelBinding(org.glassfish.api.admin.config.ModelBinding) Attribute(org.jvnet.hk2.config.Attribute) Param(org.glassfish.api.Param) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 Param (org.glassfish.api.Param)1 ModelBinding (org.glassfish.api.admin.config.ModelBinding)1 Attribute (org.jvnet.hk2.config.Attribute)1