public class SimpleRepeatableMappingRegistry extends Object implements RepeatableMappingRegistry
RepeatableMappingRegistry的简单实现。
调用者可以通过注册不同的映射关系解析器RepeatableMappingParser
从而支持基于不同规则构建容器注解与元素注解的映射关系。
RepeatableMappingParser,
StandardRepeatableMappingParser,
RepeatableByMappingParser| 限定符和类型 | 字段和说明 |
|---|---|
protected ForestMap<Class<? extends Annotation>,RepeatableMapping> |
mappingForestMap
映射关系
|
protected List<RepeatableMappingParser> |
mappingParsers
解析器
|
| 构造器和说明 |
|---|
SimpleRepeatableMappingRegistry(RepeatableMappingParser... parsers)
构造一个支持
Repeatable注解的容器关系映射表 |
| 限定符和类型 | 方法和说明 |
|---|---|
List<Annotation> |
getAllElementsFromContainer(Annotation container)
获取包括自己在内的注解容器中的全部的注解
|
List<RepeatableMapping> |
getContainers(Class<? extends Annotation> annotationType)
获取指定注解的容器注解
|
<T extends Annotation> |
getElementsFromContainer(Annotation container,
Class<T> elementType)
从容器注解中获得指定的元素注解,若该容器注解不为指定对元素的容器,或任意一者为空时返回null
|
boolean |
hasContainer(Class<? extends Annotation> annotationType)
指定注解是否存容器注解
|
boolean |
isContainer(Class<? extends Annotation> annotationType)
指定注解是否为一个容器注解
|
boolean |
isContainerOf(Class<? extends Annotation> elementType,
Class<? extends Annotation> containerType)
containerType是否为elementType的容器注解 |
void |
register(Class<? extends Annotation> annotationType)
注册指定注解类,将会解析其与关联的容器或元素注解的映射关系
注意,不允许出现注解的容器注解直接或间接以其元素注解作为容器注解的情况, 即不允许出现 a -> b -> a 这种注解间循环引用的关系。 |
void |
registerMappingParser(RepeatableMappingParser mappingParser)
注册关系解析器
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateprotected final ForestMap<Class<? extends Annotation>,RepeatableMapping> mappingForestMap
protected final List<RepeatableMappingParser> mappingParsers
public SimpleRepeatableMappingRegistry(RepeatableMappingParser... parsers)
Repeatable注解的容器关系映射表parsers - 要使用的解析器public void registerMappingParser(RepeatableMappingParser mappingParser)
registerMappingParser 在接口中 RepeatableMappingRegistrymappingParser - 关系解析器public void register(Class<? extends Annotation> annotationType)
注册指定注解类,将会解析其与关联的容器或元素注解的映射关系
注意,不允许出现注解的容器注解直接或间接以其元素注解作为容器注解的情况,
即不允许出现 a -> b -> a 这种注解间循环引用的关系。
register 在接口中 RepeatableMappingRegistryannotationType - 注解类IllegalArgumentException - 当出现注解间的循环引用时抛出public boolean isContainer(Class<? extends Annotation> annotationType)
isContainer 在接口中 RepeatableMappingRegistryannotationType - 注解类型public boolean hasContainer(Class<? extends Annotation> annotationType)
hasContainer 在接口中 RepeatableMappingRegistryannotationType - 注解类型public boolean isContainerOf(Class<? extends Annotation> elementType, Class<? extends Annotation> containerType)
containerType是否为elementType的容器注解isContainerOf 在接口中 RepeatableMappingRegistryelementType - 元素注解类型containerType - 容器注解类型public List<RepeatableMapping> getContainers(Class<? extends Annotation> annotationType)
getContainers 在接口中 RepeatableMappingRegistryannotationType - 注解类型public List<Annotation> getAllElementsFromContainer(Annotation container)
getAllElementsFromContainer 在接口中 RepeatableMappingRegistrycontainer - 容器注解public <T extends Annotation> List<T> getElementsFromContainer(Annotation container, Class<T> elementType)
getElementsFromContainer 在接口中 RepeatableMappingRegistrycontainer - 容器注解对象elementType - 元素注解类型Copyright © 2022. All rights reserved.