Package cc.plural.jsonij.marshal.annotation

Examples of cc.plural.jsonij.marshal.annotation.JSONName


        for (Field field : fields) {
            ClassProperty property = new ClassProperty();
            property.setKlass(klass);
            String propertyName = field.getName();
            if (field.isAnnotationPresent(JSONName.class)) {
                JSONName jsonName = (JSONName) field.getAnnotation(JSONName.class);
                propertyName = jsonName.value();
            }
            if (field.isAnnotationPresent(JSONCollector.class)) {
                property.setCollector(true);
            }
            property.setPropertyName(propertyName);
            property.registerAccessor(field);
            property.registorMutator(field);
            propertyMap.put(propertyName, property);
        }
        Method[] methods = klass.getDeclaredMethods();
        for (Method method : methods) {
            char ch;
            String propertyName = null;
            String methodName = method.getName();
            boolean collector = false;
           
            Class<?> returnType = method.getReturnType();
            if (methodName.length() > IS_PREFIX.length() && methodName.startsWith(IS_PREFIX) && returnType == boolean.class && Character.isUpperCase(ch = methodName.charAt(IS_PREFIX.length()))) {
                if (method.isAnnotationPresent(JSONName.class)) {
                    JSONName jsonName = (JSONName) method.getAnnotation(JSONName.class);
                    propertyName = jsonName.value();
                } else {
                    propertyName = Character.toLowerCase(ch) + methodName.substring(IS_PREFIX.length() + 1, methodName.length());
                }
                if (method.isAnnotationPresent(JSONCollector.class)) {
                    collector = true;
View Full Code Here


        return name;
    }

    public static String getJSONName(AccessibleObject object) {
        String name = null;
        JSONName jsonNameAnnotation = object.getAnnotation(JSONName.class);
        if (jsonNameAnnotation != null) {
            name = jsonNameAnnotation.value();
        }
        return name;
    }
View Full Code Here

TOP

Related Classes of cc.plural.jsonij.marshal.annotation.JSONName

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.