Package com.mongodb

Class MongoCompressor

java.lang.Object
com.mongodb.MongoCompressor

public final class MongoCompressor extends Object
Metadata describing a compressor to use for sending and receiving messages to a MongoDB server.
Since:
3.6
Since server release
3.4
  • Field Details

  • Method Details

    • createSnappyCompressor

      public static MongoCompressor createSnappyCompressor()
      Create an instance for snappy compression.
      Returns:
      A compressor based on the snappy compression algorithm
      Since server release
      3.4
    • createZlibCompressor

      public static MongoCompressor createZlibCompressor()
      Create an instance for zlib compression.
      Returns:
      A compressor based on the zlib compression algorithm
      Since server release
      3.6
    • createZstdCompressor

      public static MongoCompressor createZstdCompressor()
      Create an instance for zstd compression.
      Returns:
      A compressor based on the zstd compression algorithm
      Since server release
      4.2
    • getName

      public String getName()
      Gets the name of the compressor.
      Returns:
      the non-null compressor name
    • getProperty

      @Nullable public <T> T getProperty(String key, T defaultValue)
      Gets the property with the given key.
      Type Parameters:
      T - the property value type
      Parameters:
      key - the key
      defaultValue - the default value
      Returns:
      the property value, or the default value if the property is not defined
    • getPropertyNonNull

      public <T> T getPropertyNonNull(String key, T defaultValue)
      Gets the property with the given key.
      Type Parameters:
      T - the property value type
      Parameters:
      key - the key
      defaultValue - the default value
      Returns:
      the property value, or the default value if the property is not defined
      Throws:
      IllegalArgumentException - if the value and default value are null
      Since:
      3.7
    • withProperty

      public <T> MongoCompressor withProperty(String key, T value)
      Creates a new compressor from this compressor with the given property added to it.
      Type Parameters:
      T - the property value type
      Parameters:
      key - the property key
      value - the property value
      Returns:
      the new compressor
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object