/** * Configures Gson to apply the passed in exclusion strategy during deserialization. If this * method is invoked numerous times with different exclusion strategy objects then the exclusion * strategies that were added will be applied as a disjunction rule. This means that if one of the * added exclusion strategies suggests that a field (or class) should be skipped then that field * (or object) is skipped during its deserialization. * * @param strategy an exclusion strategy to apply during deserialization. * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern * @since 1.7 */ public GsonBuilder addDeserializationExclusionStrategy(ExclusionStrategy strategy) { excluder = excluder.withExclusionStrategy(strategy, false, true); return this; }
/** * Configures Gson to apply a set of exclusion strategies during both serialization and * deserialization. Each of the {@code strategies} will be applied as a disjunction rule. This * means that if one of the {@code strategies} suggests that a field (or class) should be skipped * then that field (or object) is skipped during serialization/deserialization. * * @param strategies the set of strategy object to apply during object (de)serialization. * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern * @since 1.4 */ public GsonBuilder setExclusionStrategies(ExclusionStrategy... strategies) { for (ExclusionStrategy strategy : strategies) { excluder = excluder.withExclusionStrategy(strategy, true, true); } return this; }