Class AnnotatedFieldGsonExclusionStrategy<AnnotationT extends Annotation>

java.lang.Object
com.sap.cloud.sdk.result.AnnotatedFieldGsonExclusionStrategy<AnnotationT>
Type Parameters:
AnnotationT - The type of the annotation to check for.
All Implemented Interfaces:
com.google.gson.ExclusionStrategy

public class AnnotatedFieldGsonExclusionStrategy<AnnotationT extends Annotation> extends Object implements com.google.gson.ExclusionStrategy
Implementation of GSON ExclusionStrategy excluding all fields not annotated with the given annotation.

Typical use-case is the usage of an annotation like ElementName. JSON should only (de-)serialize fields annotated with this annotation and ignore every other field.

  • Constructor Details

    • AnnotatedFieldGsonExclusionStrategy

      public AnnotatedFieldGsonExclusionStrategy(@Nonnull Class<AnnotationT> annotationClass)
  • Method Details

    • shouldSkipField

      public boolean shouldSkipField(@Nonnull com.google.gson.FieldAttributes fieldAttributes)
      Specified by:
      shouldSkipField in interface com.google.gson.ExclusionStrategy
    • shouldSkipClass

      public boolean shouldSkipClass(@Nonnull Class<?> cls)
      Specified by:
      shouldSkipClass in interface com.google.gson.ExclusionStrategy