Java Code Examples for com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility#DEFAULT

The following examples show how to use com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility#DEFAULT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VisibilityChecker.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor that will assign given visibility value for all
 * properties.
 * 
 * @param v level to use for all property types
 */
public Std(Visibility v)
{
    // typically we shouldn't get this value; but let's handle it if we do:
    if (v == Visibility.DEFAULT) {
        _getterMinLevel = DEFAULT._getterMinLevel;
        _isGetterMinLevel = DEFAULT._isGetterMinLevel;
        _setterMinLevel = DEFAULT._setterMinLevel;
        _creatorMinLevel = DEFAULT._creatorMinLevel;
        _fieldMinLevel = DEFAULT._fieldMinLevel;
    } else {
        _getterMinLevel = v;
        _isGetterMinLevel = v;
        _setterMinLevel = v;
        _creatorMinLevel = v;
        _fieldMinLevel = v;
    }
}
 
Example 2
Source File: PropertyProcessor.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
private static boolean isSetterAutoDetected( RebindConfiguration configuration, PropertyAccessors propertyAccessors, BeanInfo info ) {
    if ( !propertyAccessors.getSetter().isPresent() ) {
        return false;
    }

    for ( Class<? extends Annotation> annotation : AUTO_DISCOVERY_ANNOTATIONS ) {
        if ( propertyAccessors.isAnnotationPresentOnSetter( annotation ) ) {
            return true;
        }
    }

    JMethod setter = propertyAccessors.getSetter().get();

    String methodName = setter.getName();
    if ( !methodName.startsWith( "set" ) || methodName.length() <= 3 ) {
        // no annotation on method and the method does not follow naming convention
        return false;
    }

    JsonAutoDetect.Visibility visibility = info.getSetterVisibility();
    if ( Visibility.DEFAULT == visibility ) {
        visibility = configuration.getDefaultSetterVisibility();
    }
    return isAutoDetected( visibility, setter.isPrivate(), setter.isProtected(), setter.isPublic(), setter
            .isDefaultAccess() );
}
 
Example 3
Source File: PropertyProcessor.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
private static boolean isFieldAutoDetected( RebindConfiguration configuration, PropertyAccessors propertyAccessors, BeanInfo info ) {
    if ( !propertyAccessors.getField().isPresent() ) {
        return false;
    }

    for ( Class<? extends Annotation> annotation : AUTO_DISCOVERY_ANNOTATIONS ) {
        if ( propertyAccessors.isAnnotationPresentOnField( annotation ) ) {
            return true;
        }
    }

    JField field = propertyAccessors.getField().get();

    JsonAutoDetect.Visibility visibility = info.getFieldVisibility();
    if ( Visibility.DEFAULT == visibility ) {
        visibility = configuration.getDefaultFieldVisibility();
    }
    return isAutoDetected( visibility, field.isPrivate(), field.isProtected(), field.isPublic(), field
            .isDefaultAccess() );
}
 
Example 4
Source File: VisibilityChecker.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Std with(Visibility v)
{
    if (v == Visibility.DEFAULT) {
        return DEFAULT;
    }
    return new Std(v);
}
 
Example 5
Source File: PropertyProcessor.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
private static boolean isGetterAutoDetected( RebindConfiguration configuration, PropertyAccessors propertyAccessors, BeanInfo info ) {
    if ( !propertyAccessors.getGetter().isPresent() ) {
        return false;
    }

    for ( Class<? extends Annotation> annotation : AUTO_DISCOVERY_ANNOTATIONS ) {
        if ( propertyAccessors.isAnnotationPresentOnGetter( annotation ) ) {
            return true;
        }
    }

    JMethod getter = propertyAccessors.getGetter().get();

    String methodName = getter.getName();
    JsonAutoDetect.Visibility visibility;
    if ( methodName.startsWith( "is" ) && methodName.length() > 2 && JPrimitiveType.BOOLEAN.equals( getter.getReturnType()
            .isPrimitive() ) ) {

        // getter method for a boolean
        visibility = info.getIsGetterVisibility();
        if ( Visibility.DEFAULT == visibility ) {
            visibility = configuration.getDefaultIsGetterVisibility();
        }

    } else if ( methodName.startsWith( "get" ) && methodName.length() > 3 ) {

        visibility = info.getGetterVisibility();
        if ( Visibility.DEFAULT == visibility ) {
            visibility = configuration.getDefaultGetterVisibility();
        }

    } else {
        // no annotation on method and the method does not follow naming convention
        return false;
    }
    return isAutoDetected( visibility, getter.isPrivate(), getter.isProtected(), getter.isPublic(), getter.isDefaultAccess() );
}
 
Example 6
Source File: VisibilityChecker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private Visibility _defaultOrOverride(Visibility defaults, Visibility override) {
    if (override == Visibility.DEFAULT) {
        return defaults;
    }
    return override;
}
 
Example 7
Source File: VisibilityChecker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Std withGetterVisibility(Visibility v) {
    if (v == Visibility.DEFAULT) v = DEFAULT._getterMinLevel;
    if (_getterMinLevel == v) return this;
    return new Std(v, _isGetterMinLevel, _setterMinLevel, _creatorMinLevel, _fieldMinLevel);
}
 
Example 8
Source File: VisibilityChecker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Std withIsGetterVisibility(Visibility v) {
    if (v == Visibility.DEFAULT) v = DEFAULT._isGetterMinLevel;
    if (_isGetterMinLevel == v) return this;
    return new Std(_getterMinLevel, v, _setterMinLevel, _creatorMinLevel, _fieldMinLevel);
}
 
Example 9
Source File: VisibilityChecker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Std withSetterVisibility(Visibility v) {
    if (v == Visibility.DEFAULT) v = DEFAULT._setterMinLevel;
    if (_setterMinLevel == v) return this;
    return new Std(_getterMinLevel, _isGetterMinLevel, v, _creatorMinLevel, _fieldMinLevel);
}
 
Example 10
Source File: VisibilityChecker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Std withCreatorVisibility(Visibility v) {
    if (v == Visibility.DEFAULT) v = DEFAULT._creatorMinLevel;
    if (_creatorMinLevel == v) return this;
    return new Std(_getterMinLevel, _isGetterMinLevel, _setterMinLevel, v, _fieldMinLevel);
}
 
Example 11
Source File: VisibilityChecker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Std withFieldVisibility(Visibility v) {
    if (v == Visibility.DEFAULT)  v = DEFAULT._fieldMinLevel;
    if (_fieldMinLevel == v) return this;
    return new Std(_getterMinLevel, _isGetterMinLevel, _setterMinLevel, _creatorMinLevel, v);
}