java.lang.Object
org.springframework.data.redis.core.convert.Bucket

public class Bucket extends Object
Bucket is the data bag for Redis hash structures to be used with RedisData.
Since:
1.7
Author:
Christoph Strobl, Mark Paluch, Stefan Berger
  • Field Details

    • CHARSET

      public static final Charset CHARSET
      Encoding used for converting Byte to and from String.
  • Constructor Details

    • Bucket

      public Bucket()
      Creates a new empty bucket.
  • Method Details

    • put

      public void put(String path, @Nullable byte[] value)
      Add String representation of property dot path with given value.
      Parameters:
      path - must not be null or String.isEmpty().
      value - can be null.
    • remove

      public void remove(String path)
      Remove the property at property dot path.
      Parameters:
      path - must not be null or String.isEmpty().
    • get

      @Nullable public byte[] get(String path)
      Get value assigned with path.
      Parameters:
      path - must not be null or String.isEmpty().
      Returns:
      null if not set.
    • hasValue

      public boolean hasValue(String path)
      Return whether path is associated with a non-null value.
      Parameters:
      path - must not be null or String.isEmpty().
      Returns:
      true if the path is associated with a non-null value.
      Since:
      2.5
    • entrySet

      public Set<Map.Entry<String,byte[]>> entrySet()
      A set view of the mappings contained in this bucket.
      Returns:
      never null.
    • isEmpty

      public boolean isEmpty()
      Returns:
      true when no data present in Bucket.
    • size

      public int size()
      Returns:
      the number of key-value mappings of the Bucket.
    • values

      public Collection<byte[]> values()
      Returns:
      never null.
    • keySet

      public Set<String> keySet()
      Returns:
      never null.
    • asMap

      public Map<String,byte[]> asMap()
      Key/value pairs contained in the Bucket.
      Returns:
      never null.
    • extract

      public Bucket extract(String prefix)
      Extracts a bucket containing key/value pairs with the prefix.
      Parameters:
      prefix -
      Returns:
    • extractAllKeysFor

      public Set<String> extractAllKeysFor(String path)
      Get all the keys matching a given path.
      Parameters:
      path - the path to look for. Can be null.
      Returns:
      all keys if path is or empty.
    • rawMap

      public Map<byte[],byte[]> rawMap()
      Get keys and values in binary format.
      Returns:
      never null.
    • getPath

      public Bucket.BucketPropertyPath getPath()
      Get the Bucket.BucketPropertyPath leading to the current Bucket.
      Returns:
      new instance of Bucket.BucketPropertyPath.
      Since:
      2.1
    • getPropertyPath

      public Bucket.BucketPropertyPath getPropertyPath(String property)
      Get the Bucket.BucketPropertyPath for a given property within the current Bucket.
      Parameters:
      property - the property to look up.
      Returns:
      new instance of Bucket.BucketPropertyPath.
      Since:
      2.1
    • newBucketFromRawMap

      public static Bucket newBucketFromRawMap(Map<byte[],byte[]> source)
      Creates a new Bucket from a given raw map.
      Parameters:
      source - can be null.
      Returns:
      never null.
    • newBucketFromStringMap

      public static Bucket newBucketFromStringMap(Map<String,String> source)
      Creates a new Bucket from a given String map.
      Parameters:
      source - can be null.
      Returns:
      never null.
    • toString

      public String toString()
      Overrides:
      toString in class Object