Record Class ServiceEntry<S>
java.lang.Object
java.lang.Record
cloud.opencode.base.classloader.service.ServiceEntry<S>
- Type Parameters:
S- the service type | 服务类型- Record Components:
service- the service instance | 服务实例classLoaderName- the name of the ClassLoader that loaded this service | 加载此服务的类加载器名称priority- priority value (lower = higher priority) | 优先级值(值越小优先级越高)
- All Implemented Interfaces:
Comparable<ServiceEntry<S>>
public record ServiceEntry<S>(S service, String classLoaderName, int priority)
extends Record
implements Comparable<ServiceEntry<S>>
Service Entry - Wrapper for a service discovered via cross-ClassLoader lookup
服务条目 - 跨类加载器查找发现的服务包装器
Holds the service instance, the name of its originating ClassLoader, and a priority value used for ordering.
持有服务实例、来源类加载器名称以及用于排序的优先级值。
Features | 主要功能:
- Immutable record wrapping a service instance - 不可变记录,包装服务实例
- Comparable by priority (lower = higher priority) - 按优先级比较(值越小优先级越高)
- Stores ClassLoader name, not a strong reference - 存储类加载器名称,非强引用
Usage Examples | 使用示例:
ServiceEntry<MyService> entry = new ServiceEntry<>(impl, "AppClassLoader", 100);
int p = entry.priority();
MyService svc = entry.service();
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Since:
- JDK 25, opencode-base-classloader V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionServiceEntry(S service, String classLoaderName, int priority) Canonical constructor with null checks. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theclassLoaderNamerecord component.intcompareTo(ServiceEntry<S> other) Compare by priority ascending (lower value = higher priority).final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intpriority()Returns the value of thepriorityrecord component.service()Returns the value of theservicerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ServiceEntry
-
-
Method Details
-
compareTo
Compare by priority ascending (lower value = higher priority). 按优先级升序比较(值越小优先级越高)。- Specified by:
compareToin interfaceComparable<S>- Parameters:
other- the other entry to compare | 要比较的另一个条目- Returns:
- comparison result | 比较结果
-
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. -
service
-
classLoaderName
Returns the value of theclassLoaderNamerecord component.- Returns:
- the value of the
classLoaderNamerecord component
-
priority
-