Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.PropertyNamingStrategy


    @Override
    public LinkedHashMap<String,AnnotatedMethod> findGetters(VisibilityChecker<?> visibilityChecker,
            Collection<String> ignoredProperties)
    {
        LinkedHashMap<String,AnnotatedMethod> results = new LinkedHashMap<String,AnnotatedMethod>();
        final PropertyNamingStrategy naming = _config.getPropertyNamingStrategy();
        for (AnnotatedMethod am : _classInfo.memberMethods()) {
            /* note: signature has already been checked to some degree
             * via filters; however, no checks were done for arg count
             */
            // 16-May-2009, tatu: JsonIgnore processed earlier already
            if (am.getParameterCount() != 0) {
                continue;
            }
            /* So far so good: final check, then; has to either
             * (a) be marked with JsonProperty (/JsonGetter/JsonSerialize) OR
             * (b) be public AND have suitable name (getXxx or isXxx)
             */
            String propName = _annotationIntrospector.findGettablePropertyName(am);
            if (propName != null) {
                /* As per [JACKSON-64], let's still use mangled name if possible;
                 * and only if not use unmodified method name
                 */
                if (propName.length() == 0) {
                    propName = okNameForAnyGetter(am, am.getName());
                    if (propName == null) {
                        propName = am.getName();
                    }
                    // [JACKSON-178] Also, allow renaming via strategy
                    if (naming != null) {
                        propName = naming.nameForGetterMethod(_config, am, propName);
                    }
                }
            } else {
                propName = am.getName();
                // [JACKSON-166], need to separate getXxx/isXxx methods
                if (propName.startsWith("get")) { // nope, but is public bean-getter name?
                    if (!visibilityChecker.isGetterVisible(am)) {
                        continue;
                    }
                    propName = okNameForGetter(am, propName);
                } else {
                    if (!visibilityChecker.isIsGetterVisible(am)) {
                        continue;
                    }
                    propName = okNameForIsGetter(am, propName);
                }
                // null return value means 'not valid'
                if (propName == null) continue;
                // [JACKSON-384] Plus, should not include "AnyGetter" as regular getter..
                if (_annotationIntrospector.hasAnyGetterAnnotation(am)) continue;

                // [JACKSON-178] Also, allow renaming via strategy
                if (naming != null) {
                    propName = naming.nameForGetterMethod(_config, am, propName);
                }
            }

            if (ignoredProperties != null) {
                if (ignoredProperties.contains(propName)) {
View Full Code Here


    @Override
    public LinkedHashMap<String,AnnotatedMethod> findSetters(VisibilityChecker<?> vchecker)
    {
        LinkedHashMap<String,AnnotatedMethod> results = new LinkedHashMap<String,AnnotatedMethod>();
        final PropertyNamingStrategy naming = _config.getPropertyNamingStrategy();
        for (AnnotatedMethod am : _classInfo.memberMethods()) {
            // note: signature has already been checked via filters

            // Arg count != 1 (JsonIgnore checked earlier)
            if (am.getParameterCount() != 1) {
                continue;
            }

            /* So far so good: final check, then; has to either
             * (a) be marked with JsonProperty (/JsonSetter/JsonDeserialize) OR
             * (b) have suitable name (setXxx) (NOTE: need not be
             *    public, unlike with getters)
             */
            String propName = _annotationIntrospector.findSettablePropertyName(am);
            if (propName != null) { // annotation was found
                /* As per [JACKSON-64], let's still use mangled name if
                 * possible; and only if not use unmodified method name
                 */
                if (propName.length() == 0) {
                    propName = okNameForSetter(am);
                    // null means it's not named as a Bean getter; fine, use as is
                    if (propName == null) {
                        propName = am.getName();
                    }
                    // [JACKSON-178] Also, allow renaming via strategy
                    if (naming != null) {
                        propName = naming.nameForSetterMethod(_config, am, propName);
                    }
                }
            } else { // nope, but is public bean-setter name?
                if (!vchecker.isSetterVisible(am)) {
                    continue;
                }
                propName = okNameForSetter(am);
                if (propName == null) { // null means 'not valid'
                    continue;
                }
                // [JACKSON-178] Also, allow renaming via strategy
                if (naming != null) {
                    propName = naming.nameForSetterMethod(_config, am, propName);
                }
            }

            /* Yup, it is a valid name. But now... do we have a conflict?
             * If so, should throw an exception
View Full Code Here

     */
    public LinkedHashMap<String,AnnotatedField> _findPropertyFields(VisibilityChecker<?> vchecker,
            Collection<String> ignoredProperties, boolean forSerialization)
    {
        LinkedHashMap<String,AnnotatedField> results = new LinkedHashMap<String,AnnotatedField>();
        final PropertyNamingStrategy naming = _config.getPropertyNamingStrategy();
        for (AnnotatedField af : _classInfo.fields()) {
            /* note: some pre-filtering has been; no static or transient fields
             * included; nor anything marked as ignorable (@JsonIgnore).
             * Field masking has also been resolved, but it is still possible
             * to get conflicts due to logical name overwrites.
             */

            /* So far so good: final check, then; has to either
             * (a) be marked with JsonProperty (or JsonSerialize) OR
             * (b) be public
             */
            String propName = forSerialization
                ? _annotationIntrospector.findSerializablePropertyName(af)
                : _annotationIntrospector.findDeserializablePropertyName(af)
                ;
            if (propName != null) { // is annotated
                if (propName.length() == 0) {
                    propName = af.getName();
                    // [JACKSON-178] Also, allow renaming via strategy
                    if (naming != null) {
                        propName = naming.nameForField(_config, af, propName);
                    }
                }
            } else { // nope, but may be visible (usually, public, can be recofingured)
                if (!vchecker.isFieldVisible(af)) {
                    continue;
                }
                propName = af.getName();
                // [JACKSON-178] Also, allow renaming via strategy
                if (naming != null) {
                    propName = naming.nameForField(_config, af, propName);
                }
            }

            if (ignoredProperties != null) {
                if (ignoredProperties.contains(propName)) {
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.map.PropertyNamingStrategy

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.