static boolean excludeField(Field f, boolean serialize, Excluder excluder) { return !excluder.excludeClass(f.getType(), serialize) && !excluder.excludeField(f, serialize); }
public Excluder disableInnerClassSerialization() { Excluder result = clone(); result.serializeInnerClasses = false; return result; }
/** * Configures Gson to exclude inner classes during serialization. * * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern * @since 1.3 */ public GsonBuilder disableInnerClassSerialization() { excluder = excluder.disableInnerClassSerialization(); return this; }
private boolean isValidVersion(Since since, Until until) { return isValidSince(since) && isValidUntil(until); }
private boolean excludeClassChecks(Class<?> clazz) { if (version != Excluder.IGNORE_VERSIONS && !isValidVersion(clazz.getAnnotation(Since.class), clazz.getAnnotation(Until.class))) { return true; } if (!serializeInnerClasses && isInnerClass(clazz)) { return true; } if (isAnonymousOrLocal(clazz)) { return true; } return false; }
public <T> TypeAdapter<T> create(final Gson gson, final TypeToken<T> type) { Class<?> rawType = type.getRawType(); final boolean skipSerialize = excludeClass(rawType, true); final boolean skipDeserialize = excludeClass(rawType, false);
/** * Configures Gson to exclude all fields from consideration for serialization or deserialization * that do not have the {@link com.google.gson.annotations.Expose} annotation. * * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern */ public GsonBuilder excludeFieldsWithoutExposeAnnotation() { excluder = excluder.excludeFieldsWithoutExposeAnnotation(); return this; }
private boolean isInnerClass(Class<?> clazz) { return clazz.isMemberClass() && !isStatic(clazz); }
&& !isValidVersion(field.getAnnotation(Since.class), field.getAnnotation(Until.class))) { return true; if (!serializeInnerClasses && isInnerClass(field.getType())) { return true; if (isAnonymousOrLocal(field.getType())) { return true;
private boolean isValidVersion(Since since, Until until) { return isValidSince(since) && isValidUntil(until); }
public <T> TypeAdapter<T> create(final Gson gson, final TypeToken<T> type) { Class<?> rawType = type.getRawType(); final boolean skipSerialize = excludeClass(rawType, true); final boolean skipDeserialize = excludeClass(rawType, false);
/** * Configures Gson to exclude all fields from consideration for serialization or deserialization * that do not have the {@link com.google.gson.annotations.Expose} annotation. * * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern */ public GsonBuilder excludeFieldsWithoutExposeAnnotation() { excluder = excluder.excludeFieldsWithoutExposeAnnotation(); return this; }
private boolean isInnerClass(Class<?> clazz) { return clazz.isMemberClass() && !isStatic(clazz); }
public boolean excludeClass(Class<?> clazz, boolean serialize) { if (version != Excluder.IGNORE_VERSIONS && !isValidVersion(clazz.getAnnotation(Since.class), clazz.getAnnotation(Until.class))) { return true; } if (!serializeInnerClasses && isInnerClass(clazz)) { return true; } if (isAnonymousOrLocal(clazz)) { return true; } List<ExclusionStrategy> list = serialize ? serializationStrategies : deserializationStrategies; for (ExclusionStrategy exclusionStrategy : list) { if (exclusionStrategy.shouldSkipClass(clazz)) { return true; } } return false; }
public boolean excludeField(Field f, boolean serialize) { return !this.excluder.excludeClass(f.getType(), serialize) && !this.excluder.excludeField(f, serialize); }
public Excluder excludeFieldsWithoutExposeAnnotation() { Excluder result = clone(); result.requireExpose = true; return result; }
private boolean isValidVersion(Since since, Until until) { return isValidSince(since) && isValidUntil(until); }
public <T> TypeAdapter<T> create(final Gson gson, final TypeToken<T> type) { Class<?> rawType = type.getRawType(); final boolean skipSerialize = excludeClass(rawType, true); final boolean skipDeserialize = excludeClass(rawType, false);
/** * Configures Gson to exclude inner classes during serialization. * * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern * @since 1.3 */ public GsonBuilder disableInnerClassSerialization() { excluder = excluder.disableInnerClassSerialization(); return this; }
/** * Configures Gson to exclude all fields from consideration for serialization or deserialization * that do not have the {@link com.google.gson.annotations.Expose} annotation. * * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern */ public GsonBuilder excludeFieldsWithoutExposeAnnotation() { excluder = excluder.excludeFieldsWithoutExposeAnnotation(); return this; }