Class GsonDocumentExclusionStrategy

java.lang.Object
eu.cloudnetservice.driver.impl.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 Summary

    Fields
    Modifier and Type
    Field
    Description
    The jvm static exclusion strategy for the deserialize direction.
    private final eu.cloudnetservice.driver.document.annotations.DocumentValueIgnore.Direction
     
    The jvm static exclusion strategy for the serialize direction.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    GsonDocumentExclusionStrategy(eu.cloudnetservice.driver.document.annotations.DocumentValueIgnore.Direction direction)
    Constructs a new exclusion strategy that ignores members that are annotated with DocumentValueIgnore and exclude the given direction.
  • Method Summary

    Modifier and Type
    Method
    Description
    private boolean
    shouldExclude(@Nullable eu.cloudnetservice.driver.document.annotations.DocumentValueIgnore ignoreAnnotation)
    Check if the given annotation instance is present and disables the serialisation into the direction handled by this exclusion strategy.
    boolean
    boolean
    shouldSkipField(@NonNull com.google.gson.FieldAttributes field)

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SERIALIZE

      public static final GsonDocumentExclusionStrategy SERIALIZE
      The jvm static exclusion strategy for the serialize direction.
    • DESERIALIZE

      public static final GsonDocumentExclusionStrategy DESERIALIZE
      The jvm static exclusion strategy for the deserialize direction.
    • direction

      private final eu.cloudnetservice.driver.document.annotations.DocumentValueIgnore.Direction direction
  • Constructor Details

    • GsonDocumentExclusionStrategy

      private GsonDocumentExclusionStrategy(@NonNull eu.cloudnetservice.driver.document.annotations.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 eu.cloudnetservice.driver.document.annotations.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.