Android Excluder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Excluder class.

This code example shows how to use the following methods:excludeField
    assertFalse(excluder.excludeClass(MockObject.class, false));
  } 
 
  public void testSkipNonAnnotatedFields() throws Exception { 
    Field f = createFieldAttributes("hiddenField");
    assertTrue(excluder.excludeField(f, true));
    assertTrue(excluder.excludeField(f, false));
  } 
 
  public void testSkipExplicitlySkippedFields() throws Exception { 
    Field f = createFieldAttributes("explicitlyHiddenField");
    assertTrue(excluder.excludeField(f, true));
    assertTrue(excluder.excludeField(f, false));
  } 
 
  public void testNeverSkipExposedAnnotatedFields() throws Exception { 
    Field f = createFieldAttributes("exposedField");
    assertFalse(excluder.excludeField(f, true));
    assertFalse(excluder.excludeField(f, false));
  } 
4
CodeRank
This code example shows how to use the following methods:excludeClass, excludeField
    this.fieldNamingPolicy = fieldNamingPolicy;
    this.excluder = excluder;
  } 
 
  public boolean excludeField(Field f, boolean serialize) {
    return !excluder.excludeClass(f.getType(), serialize) && !excluder.excludeField(f, serialize);
  } 
 
  private String getFieldName(Field f) {
    SerializedName serializedName = f.getAnnotation(SerializedName.class);
    return serializedName == null ? fieldNamingPolicy.translateName(f) : serializedName.value();
  } 
 
  public <T> TypeAdapter<T> create(Gson gson, final TypeToken<T> type) {
    Class<? super T> raw = type.getRawType();
 
    if (!Object.class.isAssignableFrom(raw)) {
      return null; // it's a primitive! 
    } 
 
4
CodeRank
This code example shows how to use the following methods:withExclusionStrategy
   * @param strategy an exclusion strategy to apply during serialization. 
   * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern 
   * @since 1.7 
   */ 
  public GsonBuilder addSerializationExclusionStrategy(ExclusionStrategy strategy) {
    excluder = excluder.withExclusionStrategy(strategy, true, false);
    return this;
  } 
 
  /** 
   * 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 
2
CodeRank