Class GsonDocumentExclusionStrategy

java.lang.Object
eu.cloudnetservice.driver.document.gson.GsonDocumentExclusionStrategy
All Implemented Interfaces:
com.google.gson.ExclusionStrategy

final class GsonDocumentExclusionStrategy extends Object implements com.google.gson.ExclusionStrategy
An exclusion strategy implementation that takes the DocumentValueIgnore annotation into account.
Since:
4.0
  • Field Details

  • Constructor Details

    • GsonDocumentExclusionStrategy

      private GsonDocumentExclusionStrategy(@NonNull DocumentValueIgnore.Direction direction)
      Constructs a new exclusion strategy that ignores members that are annotated with DocumentValueIgnore and exclude the given direction.
      Parameters:
      direction - the serialize direction of members to exclude.
      Throws:
      NullPointerException - if the given direction is null.
  • Method Details

    • shouldSkipField

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

      public boolean shouldSkipClass(@NonNull @NonNull Class<?> clazz)
      Specified by:
      shouldSkipClass in interface com.google.gson.ExclusionStrategy
    • shouldExclude

      private boolean shouldExclude(@Nullable @Nullable DocumentValueIgnore ignoreAnnotation)
      Check if the given annotation instance is present and disables the serialisation into the direction handled by this exclusion strategy.
      Parameters:
      ignoreAnnotation - the optional ignore annotation instance to validate.
      Returns:
      true if the member should be excluded from the target direction, false otherwise.