當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。