Package au.net.ocean.maven.plugin.annotation

Examples of au.net.ocean.maven.plugin.annotation.Parameter


    }

    private org.apache.maven.plugin.descriptor.Parameter extractParameter(Field field) throws DuplicateParameterException {
        getLogger().debug("scanning field: " + field.getName());
        org.apache.maven.plugin.descriptor.Parameter parameterDescriptor = null;
        Parameter parameter = field.getAnnotation(Parameter.class);
        Component component = field.getAnnotation(Component.class);
        if (parameter != null || component != null) {
            Class<?> type = field.getType();
            StringBuffer typeNameBuffer = new StringBuffer();
            while (type.isArray()) {
                typeNameBuffer.append("[]");
                type = type.getComponentType();
            }
            String typeName = typeNameBuffer.insert(0, type.getName()).toString();
            parameterDescriptor = new org.apache.maven.plugin.descriptor.Parameter();
            parameterDescriptor.setType(typeName);
            // component overrides parameter if both are present
            if (component != null) {
                getLogger().info("found @Component: (" + typeName + "):" + field.getName());
                parameterDescriptor.setDescription(component.description());
                String role = component.role().trim();
                if (role.length() == 0) {
                    role = typeName;
                }
                String roleHint = component.roleHint().trim();
                if (roleHint.length() == 0) {
                    roleHint = null;
                }
                parameterDescriptor.setRequirement(new Requirement(role, roleHint));
                parameterDescriptor.setName(field.getName());
            } else {
                getLogger().info("found @Parameter: (" + typeName + "):" + field.getName());
                parameterDescriptor.setDescription(parameter.description());
                String property = parameter.property().trim();
                parameterDescriptor.setName(property.length() > 0 ? property : field.getName());
                parameterDescriptor.setRequired(field.isAnnotationPresent(Required.class));
                parameterDescriptor.setEditable(!field.isAnnotationPresent(ReadOnly.class));
//                    DocletTag deprecationTag = field.getTagByName(DEPRECATED);
//                    if (deprecationTag != null) {
//                        parameterDescriptor.setDeprecated(deprecationTag.getValue());
//                    }
                String alias = parameter.alias().trim();
                if (alias.length() > 0) {
                    parameterDescriptor.setAlias(alias);
                }
                parameterDescriptor.setExpression(parameter.expression().trim());
                parameterDescriptor.setDefaultValue(parameter.defaultValue());
            }
        }
        return parameterDescriptor;
    }
View Full Code Here


    }

    private org.apache.maven.plugin.descriptor.Parameter extractParameter(Field field) throws DuplicateParameterException {
        getLogger().debug("scanning field: " + field.getName());
        org.apache.maven.plugin.descriptor.Parameter parameterDescriptor = null;
        Parameter parameter = field.getAnnotation(Parameter.class);
        Component component = field.getAnnotation(Component.class);
        if (parameter != null || component != null) {
            Class<?> type = field.getType();
            StringBuffer typeNameBuffer = new StringBuffer();
            while (type.isArray()) {
                typeNameBuffer.append("[]");
                type = type.getComponentType();
            }
            String typeName = typeNameBuffer.insert(0, type.getName()).toString();
            parameterDescriptor = new org.apache.maven.plugin.descriptor.Parameter();
            parameterDescriptor.setType(typeName);
            // component overrides parameter if both are present
            if (component != null) {
                getLogger().info("found @Component: (" + typeName + "):" + field.getName());
                parameterDescriptor.setDescription(component.description());
                String role = component.role().trim();
                if (role.length() == 0) {
                    role = typeName;
                }
                String roleHint = component.roleHint().trim();
                if (roleHint.length() == 0) {
                    roleHint = null;
                }
                parameterDescriptor.setRequirement(new Requirement(role, roleHint));
                parameterDescriptor.setName(field.getName());
            } else {
                getLogger().info("found @Parameter: (" + typeName + "):" + field.getName());
                parameterDescriptor.setDescription(parameter.description());
                String property = parameter.property().trim();
                parameterDescriptor.setName(property.length() > 0 ? property : field.getName());
                parameterDescriptor.setRequired(field.isAnnotationPresent(Required.class));
                parameterDescriptor.setEditable(!field.isAnnotationPresent(ReadOnly.class));
//                    DocletTag deprecationTag = field.getTagByName(DEPRECATED);
//                    if (deprecationTag != null) {
//                        parameterDescriptor.setDeprecated(deprecationTag.getValue());
//                    }
                String alias = parameter.alias().trim();
                if (alias.length() > 0) {
                    parameterDescriptor.setAlias(alias);
                }
                String expression = parameter.expression().trim();
                if (expression.length() > 0) {
                    parameterDescriptor.setExpression(expression);
                }
                String defaultValue = parameter.defaultValue().trim();
                if (defaultValue.length() > 0) {
                    parameterDescriptor.setDefaultValue(defaultValue);
                }
            }
        }
View Full Code Here

TOP

Related Classes of au.net.ocean.maven.plugin.annotation.Parameter

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.