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
-
Nested Class Summary
Nested classes/interfaces inherited from interface EvictionPolicy
EvictionPolicy.Composite<T>, EvictionPolicy.IdleTime<T>, EvictionPolicy.LFU<T>, EvictionPolicy.LRU<T>, EvictionPolicy.MaxAge<T> -
Constructor Summary
ConstructorsConstructorDescriptionComposite(List<EvictionPolicy<T>> policies, boolean requireAll) Creates an instance of aCompositerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.booleanevict(PooledObject<T> obj, EvictionContext context) Determines if the object should be evicted.final inthashCode()Returns a hash code value for this object.policies()Returns the value of thepoliciesrecord component.booleanReturns the value of therequireAllrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Composite
Creates an instance of aCompositerecord class.- Parameters:
policies- the value for thepoliciesrecord componentrequireAll- the value for therequireAllrecord component
-
-
Method Details
-
evict
Description copied from interface:EvictionPolicyDetermines if the object should be evicted. 确定对象是否应被驱逐。- Specified by:
evictin interfaceEvictionPolicy<T>- Parameters:
obj- the pooled object - 池化对象context- the eviction context - 驱逐上下文- Returns:
- true if should evict - 如果应驱逐返回true
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
policies
-
requireAll
public boolean requireAll()Returns the value of therequireAllrecord component.- Returns:
- the value of the
requireAllrecord component
-