本文整理汇总了Java中com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility方法的典型用法代码示例。如果您正苦于以下问题:Java JsonAutoDetect.Visibility方法的具体用法?Java JsonAutoDetect.Visibility怎么用?Java JsonAutoDetect.Visibility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.annotation.JsonAutoDetect
的用法示例。
在下文中一共展示了JsonAutoDetect.Visibility方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVisibility
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
private Visibility getVisibility(JsonAutoDetect.Visibility visibility, Visibility defaultVisibility) {
switch (visibility) {
case DEFAULT:
return defaultVisibility;
case ANY:
return Visibility.ANY;
case NON_PRIVATE:
return Visibility.NON_PRIVATE;
case NONE:
return Visibility.NONE;
case PROTECTED_AND_PUBLIC:
return Visibility.PROTECTED_AND_PUBLIC;
case PUBLIC_ONLY:
return Visibility.PUBLIC_ONLY;
}
throw new AssertionError("Unsupported visibility:" + visibility);
}
示例2: Std
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public Std(JsonAutoDetect.Visibility paramVisibility)
{
if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT)
{
this._getterMinLevel = DEFAULT._getterMinLevel;
this._isGetterMinLevel = DEFAULT._isGetterMinLevel;
this._setterMinLevel = DEFAULT._setterMinLevel;
this._creatorMinLevel = DEFAULT._creatorMinLevel;
this._fieldMinLevel = DEFAULT._fieldMinLevel;
return;
}
this._getterMinLevel = paramVisibility;
this._isGetterMinLevel = paramVisibility;
this._setterMinLevel = paramVisibility;
this._creatorMinLevel = paramVisibility;
this._fieldMinLevel = paramVisibility;
}
示例3: withVisibility
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public Std withVisibility(PropertyAccessor paramPropertyAccessor, JsonAutoDetect.Visibility paramVisibility)
{
switch (VisibilityChecker.1.$SwitchMap$com$fasterxml$jackson$annotation$PropertyAccessor[paramPropertyAccessor.ordinal()])
{
default:
return this;
case 1:
return withGetterVisibility(paramVisibility);
case 2:
return withSetterVisibility(paramVisibility);
case 3:
return withCreatorVisibility(paramVisibility);
case 4:
return withFieldVisibility(paramVisibility);
case 5:
return withIsGetterVisibility(paramVisibility);
case 6:
}
return with(paramVisibility);
}
示例4: fromJson
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public static <T> T fromJson(String json, Class<T> entityClass, JsonAutoDetect.Visibility visibility)
{
T instance = null;
// Need to make this local to be thread safe
ObjectMapper localMapper = new ObjectMapper();
localMapper.setVisibility(PropertyAccessor.FIELD, visibility);
try
{
instance = localMapper.readValue(json, entityClass);
} catch (IOException e)
{
e.printStackTrace();
}
return instance;
}
示例5: toJson
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public static String toJson(Object object, JsonAutoDetect.Visibility visibility)
{
String json = null;
// Need to make this local to be thread safe
ObjectMapper localMapper = new ObjectMapper();
localMapper.setVisibility(PropertyAccessor.FIELD, visibility);
try
{
json = localMapper.writeValueAsString(object);
} catch (JsonProcessingException e)
{
if (LOG.isDebugEnabled())
{
e.printStackTrace();
}
LOG.error("Unable to convert object to JSON: {}", e.getMessage());
}
return json;
}
示例6: isSetterAutoDetected
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
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() );
}
示例7: isFieldAutoDetected
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
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() );
}
示例8: isAutoDetected
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
private static boolean isAutoDetected( JsonAutoDetect.Visibility visibility, boolean isPrivate, boolean isProtected, boolean
isPublic, boolean isDefaultAccess ) {
switch ( visibility ) {
case ANY:
return true;
case NONE:
return false;
case NON_PRIVATE:
return !isPrivate;
case PROTECTED_AND_PUBLIC:
return isProtected || isPublic;
case PUBLIC_ONLY:
case DEFAULT:
return isPublic;
default:
return false;
}
}
示例9: withCreatorVisibility
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public Std withCreatorVisibility(JsonAutoDetect.Visibility paramVisibility)
{
if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT)
paramVisibility = DEFAULT._creatorMinLevel;
if (this._creatorMinLevel == paramVisibility)
return this;
JsonAutoDetect.Visibility localVisibility1 = this._getterMinLevel;
JsonAutoDetect.Visibility localVisibility2 = this._isGetterMinLevel;
JsonAutoDetect.Visibility localVisibility3 = this._setterMinLevel;
JsonAutoDetect.Visibility localVisibility4 = this._fieldMinLevel;
return new Std(localVisibility1, localVisibility2, localVisibility3, paramVisibility, localVisibility4);
}
示例10: withFieldVisibility
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public Std withFieldVisibility(JsonAutoDetect.Visibility paramVisibility)
{
if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT)
paramVisibility = DEFAULT._fieldMinLevel;
if (this._fieldMinLevel == paramVisibility)
return this;
return new Std(this._getterMinLevel, this._isGetterMinLevel, this._setterMinLevel, this._creatorMinLevel, paramVisibility);
}
示例11: withGetterVisibility
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public Std withGetterVisibility(JsonAutoDetect.Visibility paramVisibility)
{
if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT)
paramVisibility = DEFAULT._getterMinLevel;
if (this._getterMinLevel == paramVisibility)
return this;
JsonAutoDetect.Visibility localVisibility1 = this._isGetterMinLevel;
JsonAutoDetect.Visibility localVisibility2 = this._setterMinLevel;
JsonAutoDetect.Visibility localVisibility3 = this._creatorMinLevel;
JsonAutoDetect.Visibility localVisibility4 = this._fieldMinLevel;
return new Std(paramVisibility, localVisibility1, localVisibility2, localVisibility3, localVisibility4);
}
示例12: withIsGetterVisibility
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public Std withIsGetterVisibility(JsonAutoDetect.Visibility paramVisibility)
{
if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT)
paramVisibility = DEFAULT._isGetterMinLevel;
if (this._isGetterMinLevel == paramVisibility)
return this;
JsonAutoDetect.Visibility localVisibility1 = this._getterMinLevel;
JsonAutoDetect.Visibility localVisibility2 = this._setterMinLevel;
JsonAutoDetect.Visibility localVisibility3 = this._creatorMinLevel;
JsonAutoDetect.Visibility localVisibility4 = this._fieldMinLevel;
return new Std(localVisibility1, paramVisibility, localVisibility2, localVisibility3, localVisibility4);
}
示例13: withSetterVisibility
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public Std withSetterVisibility(JsonAutoDetect.Visibility paramVisibility)
{
if (paramVisibility == JsonAutoDetect.Visibility.DEFAULT)
paramVisibility = DEFAULT._setterMinLevel;
if (this._setterMinLevel == paramVisibility)
return this;
JsonAutoDetect.Visibility localVisibility1 = this._getterMinLevel;
JsonAutoDetect.Visibility localVisibility2 = this._isGetterMinLevel;
JsonAutoDetect.Visibility localVisibility3 = this._creatorMinLevel;
JsonAutoDetect.Visibility localVisibility4 = this._fieldMinLevel;
return new Std(localVisibility1, localVisibility2, paramVisibility, localVisibility3, localVisibility4);
}
示例14: isGetterAutoDetected
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
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() );
}
示例15: withVisibility
import com.fasterxml.jackson.annotation.JsonAutoDetect; //导入方法依赖的package包/类
public BaseSettings withVisibility(PropertyAccessor forMethod, JsonAutoDetect.Visibility visibility) {
return new BaseSettings(_classIntrospector, _annotationIntrospector,
_visibilityChecker.withVisibility(forMethod, visibility),
_propertyNamingStrategy, _typeFactory,
_typeResolverBuilder, _dateFormat, _handlerInstantiator, _locale,
_timeZone, _defaultBase64);
}