本文整理匯總了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;
}