本文整理汇总了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;
}
};
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例7: shouldSkipField
import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean shouldSkipField(FieldAttributes f) {
if(f.getAnnotation(Exclude.class) != null){
return true;
}
return false;
}
示例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();
}
示例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;
}
示例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;
}
示例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());
}
示例12: shouldSkipField
import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
if (fieldAttributes.getAnnotation(Param.class) != null) {
return true;
}
return false;
}
示例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;
}
示例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;
}
示例15: shouldSkipField
import com.google.gson.FieldAttributes; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes field) {
if (field.getAnnotation(JsonDeserializeIgnore.class) != null) {
return true;
}
return false;
}