当前位置: 首页>>代码示例>>Java>>正文


Java FieldAttributes.getAnnotation方法代码示例

本文整理汇总了Java中com.google.gson.FieldAttributes.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java FieldAttributes.getAnnotation方法的具体用法?Java FieldAttributes.getAnnotation怎么用?Java FieldAttributes.getAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gson.FieldAttributes的用法示例。


在下文中一共展示了FieldAttributes.getAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getExclusionStrategy

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
/**
 * Retrieves an {@link ExclusionStrategy} that excludes {@link GsonExclude} fields and the classes contained in
 * {@code excludedClasses}.
 *
 * @param strategy the type of the strategy to be retrieved
 * @return the {@link ExclusionStrategy} for the {@code strategy} provided
 */
public ExclusionStrategy getExclusionStrategy(@Nullable GsonExclude.Strategy strategy) {
  return new ExclusionStrategy() {
    @Override
    public boolean shouldSkipField(FieldAttributes fieldAttributes) {
      return shouldSkipFieldFromSerialization(fieldAttributes)
          || (fieldAttributes.getAnnotation(GsonExclude.class) != null
          && (Objects.equals(fieldAttributes.getAnnotation(GsonExclude.class).strategy(), GsonExclude.Strategy.ALL)
          || Objects.equals(fieldAttributes.getAnnotation(GsonExclude.class).strategy(), strategy)));
    }

    @Override
    public boolean shouldSkipClass(Class<?> clazz) {
      return false;
    }
  };
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:24,代码来源:GsonExclusionStrategy.java

示例2: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
public boolean shouldSkipField(final FieldAttributes f) {
    final Param param = f.getAnnotation(Param.class);
    if (param != null) {
        final RoleType[] allowedRoles = param.authorized();
        if (allowedRoles.length > 0) {
            boolean permittedParameter = false;
            final Account caller = CallContext.current().getCallingAccount();
            for (final RoleType allowedRole : allowedRoles) {
                if (allowedRole.getValue() == caller.getType()) {
                    permittedParameter = true;
                    break;
                }
            }
            if (!permittedParameter) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:21,代码来源:ApiResponseGsonHelper.java

示例3: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes f) {
    SyncanoField syncanoField = f.getAnnotation(SyncanoField.class);

    // Don't serialize read only fields (like "id" or "created_at").
    // We want only to receive it, not send.
    // SyncanoFile is handled in SendRequest
    // SyncanoObject is handled in SyncanoObjectAdapterFactory
    if (syncanoField == null ||
            (!readOnlyNotImportant && syncanoField.readOnly() && !syncanoField.required()) ||
            f.getDeclaredClass().isAssignableFrom(SyncanoFile.class) ||
            f.getDeclaredClass().isAssignableFrom(SyncanoObject.class)) {
        return true;
    }

    return false;
}
 
开发者ID:Syncano,项目名称:syncano-android,代码行数:18,代码来源:SyncanoSerializationStrategy.java

示例4: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
public boolean shouldSkipField(FieldAttributes f) {
    Param param = f.getAnnotation(Param.class);
    if (param != null) {
        RoleType[] allowedRoles = param.authorized();
        if (allowedRoles.length > 0) {
            boolean permittedParameter = false;
            Account caller = CallContext.current().getCallingAccount();
            for (RoleType allowedRole : allowedRoles) {
                if (allowedRole.getAccountType() == caller.getType()) {
                    permittedParameter = true;
                    break;
                }
            }
            if (!permittedParameter) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:21,代码来源:ApiResponseGsonHelper.java

示例5: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes f) {
	SkipSerialization annotation = f.getAnnotation(SkipSerialization.class);
	if (annotation != null)
		return true;
	
	String fieldName = f.getName();
	Class<?> definedIn = f.getDeclaringClass();

	for (Entry<String, Class<?>> include : serializee.getIncludes().entries()) {
		if (isCompatiblePath(include, definedIn, fieldName)) {
			return false;
		}
	}
	for (Entry<String, Class<?>> exclude : serializee.getExcludes().entries()) {
		if (isCompatiblePath(exclude, definedIn, fieldName)) {
			return true;
		}
	}
	
	Field field = reflectionProvider.getField(definedIn, fieldName);
	return !serializee.isRecursive() && !shouldSerializeField(field.getType());
}
 
开发者ID:caelum,项目名称:vraptor4,代码行数:24,代码来源:Exclusions.java

示例6: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes field) {
    SerializedName sname = field.getAnnotation(SerializedName.class);
    if(sname != null)
        return false;

    return true;
}
 
开发者ID:UWICompSociety,项目名称:OurVLE,代码行数:9,代码来源:GsonExclude.java

示例7: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean shouldSkipField(FieldAttributes f) {
	
	if(f.getAnnotation(Exclude.class) != null){
		return true;
	}
	
	return false;
}
 
开发者ID:mcraken,项目名称:spring-scaffy,代码行数:10,代码来源:AnnotationExeclusionStrategy.java

示例8: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(final FieldAttributes fieldAttributes) {
    Expose exposeAnnotation = fieldAttributes.getAnnotation(Expose.class);
    if (exposeAnnotation == null) {
        return false;
    }
    if (useForSerialization) {
        return !exposeAnnotation.serialize();
    }
    return !exposeAnnotation.deserialize();
}
 
开发者ID:vmware,项目名称:workflowTools,代码行数:12,代码来源:ImprovedExclusionStrategy.java

示例9: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(final FieldAttributes arg0) {
	if (arg0.getAnnotation(JsonExclude.class) != null) {
		return true;
	}
	return false;
}
 
开发者ID:KleeGroup,项目名称:vertigo-labs,代码行数:8,代码来源:JsonUtil.java

示例10: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes f) {
    SyncanoField syncanoField = f.getAnnotation(SyncanoField.class);
    // Don't serialize read only fields (like "id" or "created_at").
    // We want only to receive it, not send.
    // SyncanoFile is handled in SendRequest
    if (syncanoField == null ||
            (!serializeReadOnlyFields && syncanoField.readOnly() && !syncanoField.required()) ||
            f.getDeclaringClass().isAssignableFrom(SyncanoFile.class)) {
        return true;
    }

    return false;
}
 
开发者ID:Syncano,项目名称:syncano-android,代码行数:15,代码来源:SyncanoExclusionStrategy.java

示例11: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes f) {
    if (f.getAnnotation(DontExpose.class) != null) {
        return true;
    }

    if (fieldsToExclude == null || fieldsToExclude.isEmpty()) {
        return false;
    }

    for (String fieldToExclude : fieldsToExclude) {
        if (fieldToExclude == null || fieldToExclude.lastIndexOf('.') == -1) {
            continue;
        }

        String[] split = fieldToExclude.split("\\.");
        if (split != null && split.length > 1) {
            String fieldClassName = (split[split.length - 2]).toLowerCase();
            String fieldAttrName = (split[split.length - 1]).toLowerCase();

            String className = (className(f)).toLowerCase();
            String classAttrName = (f.getName()).toLowerCase();

            if (className.equals(fieldClassName) && classAttrName.equals(fieldAttrName)) {
                return true;
            }
        }
    }

    return fieldsToExclude.contains(f.getName());
}
 
开发者ID:cenobites,项目名称:struts2-json-plugin,代码行数:32,代码来源:JsonSerializerExclusionStrategy.java

示例12: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
    if (fieldAttributes.getAnnotation(Param.class) != null) {
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:8,代码来源:EmptyFieldExclusionStrategy.java

示例13: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes f) {
    JsonPolicyDef policyAnnotation = f.getAnnotation(JsonPolicyDef.class);
    if (policyAnnotation == null) {
        // no policy annotation - filed should be skipped
        return true;
    }
    for (JsonPolicyDef.Policy definedPolicy : policyAnnotation.value()) {
        if (definedPolicy == policy) {
            // policy is found - field is to be included
            return false;
        }
    }
    return true;
}
 
开发者ID:devicehive,项目名称:devicehive-java-server,代码行数:16,代码来源:AnnotatedStrategy.java

示例14: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
public boolean shouldSkipField(FieldAttributes f) {
	if (DEBUG) {
		System.out.println(f.getName());
		System.out.println(f.getAnnotation(GsonIgnore.class));
	}
	return f.getAnnotation(GsonIgnore.class) != null;
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:8,代码来源:GsonIgnoreStrategy.java

示例15: shouldSkipField

import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes field) {
	if (field.getAnnotation(JsonDeserializeIgnore.class) != null) {
		return true;
	}
	return false;
}
 
开发者ID:wepay,项目名称:WePay-Java-SDK,代码行数:8,代码来源:WepayExclusionStrategy.java


注:本文中的com.google.gson.FieldAttributes.getAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。