Record Class EvictionPolicy.Composite<T>

java.lang.Object
java.lang.Record
cloud.opencode.base.pool.policy.EvictionPolicy.Composite<T>
Type Parameters:
T - the pooled object type - 池化对象类型
Record Components:
policies - the policies to combine - 要组合的策略
requireAll - true for AND, false for OR - true表示AND,false表示OR
All Implemented Interfaces:
EvictionPolicy<T>
Enclosing interface:
EvictionPolicy<T>

public static record EvictionPolicy.Composite<T>(List<EvictionPolicy<T>> policies, boolean requireAll) extends Record implements EvictionPolicy<T>
Composite eviction policy. 组合驱逐策略。

Combines multiple policies with AND or OR logic.

使用AND或OR逻辑组合多个策略。

Since:
JDK 25, opencode-base-pool V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • Composite

      public Composite(List<EvictionPolicy<T>> policies, boolean requireAll)
      Creates an instance of a Composite record class.
      Parameters:
      policies - the value for the policies record component
      requireAll - the value for the requireAll record component
  • Method Details

    • evict

      public boolean evict(PooledObject<T> obj, EvictionContext context)
      Description copied from interface: EvictionPolicy
      Determines if the object should be evicted. 确定对象是否应被驱逐。
      Specified by:
      evict in interface EvictionPolicy<T>
      Parameters:
      obj - the pooled object - 池化对象
      context - the eviction context - 驱逐上下文
      Returns:
      true if should evict - 如果应驱逐返回true
    • 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.
    • policies

      public List<EvictionPolicy<T>> policies()
      Returns the value of the policies record component.
      Returns:
      the value of the policies record component
    • requireAll

      public boolean requireAll()
      Returns the value of the requireAll record component.
      Returns:
      the value of the requireAll record component