Class PermittedSubclasses
java.lang.Object
cloud.opencode.base.reflect.sealed.PermittedSubclasses
Permitted Subclasses Collection
许可子类集合
Represents the collection of permitted subclasses for a sealed class.
表示密封类的许可子类集合。
Features | 主要功能:
- Iterable access to permitted subclasses - 可迭代访问许可子类
- Filtering and streaming support - 过滤和流支持
- Subclass type checking - 子类类型检查
Usage Examples | 使用示例:
PermittedSubclasses permitted = new PermittedSubclasses(Shape.class);
for (Class<?> subclass : permitted) {
System.out.println(subclass.getSimpleName());
}
Security | 安全性:
- Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
- Null-safe: No (sealed class must be non-null) - 空值安全: 否(密封类须非空)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHierarchy node for tree representation 用于树表示的层次结构节点 -
Constructor Summary
ConstructorsConstructorDescriptionPermittedSubclasses(Class<?> sealedClass) Creates a PermittedSubclasses collection 创建PermittedSubclasses集合 -
Method Summary
Modifier and TypeMethodDescriptionGets subclasses matching a predicate 获取匹配谓词的子类Class<?> get(int index) Gets a subclass by index 按索引获取子类getAll()Gets all permitted subclasses 获取所有许可子类Gets recursively all permitted subclasses (including nested sealed classes) 递归获取所有许可子类(包括嵌套的密封类)Gets only final subclasses 仅获取final子类Gets the complete hierarchy as a tree structure 获取完整层次结构作为树结构getNames()Gets subclass names 获取子类名称Gets only non-final subclasses 仅获取非final子类Gets only record subclasses 仅获取record子类Class<?> Gets the sealed class 获取密封类Gets only sealed subclasses 仅获取密封子类Gets subclass simple names 获取子类简单名称booleanisEmpty()Checks if empty 检查是否为空booleanisPermitted(Class<?> clazz) Checks if a class is a permitted subclass 检查类是否为许可子类iterator()intsize()Gets the number of permitted subclasses 获取许可子类数量stream()Creates a stream of permitted subclasses 创建许可子类的流toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
PermittedSubclasses
Creates a PermittedSubclasses collection 创建PermittedSubclasses集合- Parameters:
sealedClass- the sealed class | 密封类
-
-
Method Details
-
getSealedClass
-
getAll
-
size
public int size()Gets the number of permitted subclasses 获取许可子类数量- Returns:
- the count | 数量
-
isEmpty
public boolean isEmpty()Checks if empty 检查是否为空- Returns:
- true if no permitted subclasses | 如果没有许可子类返回true
-
isPermitted
Checks if a class is a permitted subclass 检查类是否为许可子类- Parameters:
clazz- the class to check | 要检查的类- Returns:
- true if permitted | 如果是许可的返回true
-
get
Gets a subclass by index 按索引获取子类- Parameters:
index- the index | 索引- Returns:
- the subclass | 子类
-
filter
-
getFinalSubclasses
-
getNonFinalSubclasses
-
getSealedSubclasses
-
getRecordSubclasses
-
getNames
-
getSimpleNames
-
stream
-
getAllRecursive
-
getHierarchy
Gets the complete hierarchy as a tree structure 获取完整层次结构作为树结构- Returns:
- the hierarchy node | 层次结构节点
-
iterator
-
toString
-