java.lang.Object
org.springframework.data.redis.connection.zset.Weights

public class Weights extends Object
Value object encapsulating a multiplication factor for each input sorted set. This means that the score of every element in every input sorted set is multiplied by this factor before being passed to the aggregation function.
Since:
2.1
Author:
Mark Paluch, Christoph Strobl
  • Method Details

    • of

      public static Weights of(int... weights)
      Create new Weights given weights as int.
      Parameters:
      weights - must not be null.
      Returns:
      the Weights for weights.
    • of

      public static Weights of(double... weights)
      Create new Weights given weights as double.
      Parameters:
      weights - must not be null.
      Returns:
      the Weights for weights.
    • fromSetCount

      public static Weights fromSetCount(int count)
      Creates equal Weights for a number of input sets count with a weight of one.
      Parameters:
      count - number of input sets. Must be greater or equal to zero.
      Returns:
      equal Weights for a number of input sets with a weight of one.
    • multiply

      public Weights multiply(int multiplier)
      Creates a new Weights object that contains all weights multiplied by multiplier
      Parameters:
      multiplier - multiplier used to multiply each weight with.
      Returns:
      equal Weights for a number of input sets with a weight of one.
    • multiply

      public Weights multiply(double multiplier)
      Creates a new Weights object that contains all weights multiplied by multiplier
      Parameters:
      multiplier - multiplier used to multiply each weight with.
      Returns:
      equal Weights for a number of input sets with a weight of one.
    • apply

      public Weights apply(Function<Double,Double> operator)
      Creates a new Weights object that contains all weights with Function applied.
      Parameters:
      operator - operator function.
      Returns:
      the new Weights with DoubleUnaryOperator applied.
    • getWeight

      public double getWeight(int index)
      Retrieve the weight at index.
      Parameters:
      index - the weight index.
      Returns:
      the weight at index.
      Throws:
      IndexOutOfBoundsException - if the index is out of range
    • size

      public int size()
      Returns:
      number of weights.
    • toArray

      public double[] toArray()
      Returns:
      an array containing all of the weights in this list in proper sequence (from first to last element).
    • toList

      public List<Double> toList()
      Returns:
      a List containing all of the weights in this list in proper sequence (from first to last element).
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object