Record Class EvictionPolicy.WeightedPolicy<K,V>

java.lang.Object
java.lang.Record
cloud.opencode.base.cache.spi.EvictionPolicy.WeightedPolicy<K,V>
Type Parameters:
K - key type | 键类型
V - value type | 值类型
Record Components:
policy - the eviction policy | 淘汰策略
weight - the weight for this policy | 此策略的权重
Enclosing interface:
EvictionPolicy<K,V>

public static record EvictionPolicy.WeightedPolicy<K,V>(EvictionPolicy<K,V> policy, double weight) extends Record
Weighted policy wrapper 加权策略包装器
Since:
JDK 25, opencode-base-cache V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • WeightedPolicy

      public WeightedPolicy(EvictionPolicy<K,V> policy, double weight)
      Creates an instance of a WeightedPolicy record class.
      Parameters:
      policy - the value for the policy record component
      weight - the value for the weight record component
  • Method Details

    • of

      public static <K,V> EvictionPolicy.WeightedPolicy<K,V> of(EvictionPolicy<K,V> policy, double weight)
      Creates a weighted policy | 创建加权策略
      Type Parameters:
      K - the key type | 键类型
      V - the value type | 值类型
      Parameters:
      policy - the eviction policy | 淘汰策略
      weight - the weight | 权重
      Returns:
      the weighted policy | 加权策略
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • policy

      public EvictionPolicy<K,V> policy()
      Returns the value of the policy record component.
      Returns:
      the value of the policy record component
    • weight

      public double weight()
      Returns the value of the weight record component.
      Returns:
      the value of the weight record component