fix comment

This commit is contained in:
Looly 2022-07-05 22:38:19 +08:00
parent 6ac537d6c3
commit bc19e6a924
4 changed files with 76 additions and 53 deletions

View File

@ -32,6 +32,7 @@ public interface SynthesizedAnnotationSelector {
/** /**
* 比较两个被合成的注解选择其中的一个并返回 * 比较两个被合成的注解选择其中的一个并返回
* *
* @param <T> 复合注解类型
* @param oldAnnotation 已存在的注解该参数不允许为空 * @param oldAnnotation 已存在的注解该参数不允许为空
* @param newAnnotation 新获取的注解该参数不允许为空 * @param newAnnotation 新获取的注解该参数不允许为空
* @return 被合成的注解 * @return 被合成的注解

View File

@ -219,6 +219,9 @@ public abstract class AbstractTypeAnnotationScanner<T extends AbstractTypeAnnota
/** /**
* 当前类是否不需要处理 * 当前类是否不需要处理
*
* @param accessedTypes 访问类型
* @param targetClass 目标类型
*/ */
protected boolean isNotNeedProcess(Set<Class<?>> accessedTypes, Class<?> targetClass) { protected boolean isNotNeedProcess(Set<Class<?>> accessedTypes, Class<?> targetClass) {
return ObjectUtil.isNull(targetClass) return ObjectUtil.isNull(targetClass)
@ -229,6 +232,9 @@ public abstract class AbstractTypeAnnotationScanner<T extends AbstractTypeAnnota
/** /**
* {@link #includeInterfaces}{@code true}则将目标类的父接口也添加到nextClasses * {@link #includeInterfaces}{@code true}则将目标类的父接口也添加到nextClasses
*
* @param nextClasses 下一个类集合
* @param targetClass 目标类型
*/ */
protected void scanInterfaceIfNecessary(List<Class<?>> nextClasses, Class<?> targetClass) { protected void scanInterfaceIfNecessary(List<Class<?>> nextClasses, Class<?> targetClass) {
if (includeInterfaces) { if (includeInterfaces) {
@ -241,6 +247,9 @@ public abstract class AbstractTypeAnnotationScanner<T extends AbstractTypeAnnota
/** /**
* {@link #includeSupperClass}{@code true}则将目标类的父类也添加到nextClasses * {@link #includeSupperClass}{@code true}则将目标类的父类也添加到nextClasses
*
* @param nextClassQueue 下一个类队列
* @param targetClass 目标类型
*/ */
protected void scanSuperClassIfNecessary(List<Class<?>> nextClassQueue, Class<?> targetClass) { protected void scanSuperClassIfNecessary(List<Class<?>> nextClassQueue, Class<?> targetClass) {
if (includeSupperClass) { if (includeSupperClass) {
@ -253,6 +262,8 @@ public abstract class AbstractTypeAnnotationScanner<T extends AbstractTypeAnnota
/** /**
* 若存在转换器则使用转换器对目标类进行转换 * 若存在转换器则使用转换器对目标类进行转换
*
* @param target 目标类
*/ */
protected Class<?> convert(Class<?> target) { protected Class<?> convert(Class<?> target) {
if (hasConverters) { if (hasConverters) {

View File

@ -66,7 +66,7 @@ public interface ForestMap<K, V> extends Map<K, TreeEntry<K, V>> {
* <li>若存在父节点或子节点则将其断开其与父节点或子节点的引用关系</li> * <li>若存在父节点或子节点则将其断开其与父节点或子节点的引用关系</li>
* <li> * <li>
* 若同时存在父节点或子节点则会在删除后将让子节点直接成为父节点的子节点比如<br> * 若同时存在父节点或子节点则会在删除后将让子节点直接成为父节点的子节点比如<br>
* 现有引用关系 a -> b -> c删除 b 将有 a -> c * 现有引用关系 a -&gt; b -&gt; c删除 b 将有 a -&gt; c
* </li> * </li>
* </ul> * </ul>
* *
@ -87,6 +87,7 @@ public interface ForestMap<K, V> extends Map<K, TreeEntry<K, V>> {
/** /**
* 批量添加节点 * 批量添加节点
* *
* @param <C> 集合类型
* @param values 要添加的值 * @param values 要添加的值
* @param keyGenerator 从值中获取key的方法 * @param keyGenerator 从值中获取key的方法
* @param parentKeyGenerator 从值中获取父节点key的方法 * @param parentKeyGenerator 从值中获取父节点key的方法
@ -102,8 +103,8 @@ public interface ForestMap<K, V> extends Map<K, TreeEntry<K, V>> {
final K parentKey = parentKeyGenerator.apply(v); final K parentKey = parentKeyGenerator.apply(v);
// 不忽略keu为null节点 // 不忽略keu为null节点
boolean hasKey = ObjectUtil.isNotNull(key); final boolean hasKey = ObjectUtil.isNotNull(key);
boolean hasParentKey = ObjectUtil.isNotNull(parentKey); final boolean hasParentKey = ObjectUtil.isNotNull(parentKey);
if (!ignoreNullNode || (hasKey && hasParentKey)) { if (!ignoreNullNode || (hasKey && hasParentKey)) {
linkNodes(parentKey, key); linkNodes(parentKey, key);
get(key).setValue(v); get(key).setValue(v);
@ -207,7 +208,7 @@ public interface ForestMap<K, V> extends Map<K, TreeEntry<K, V>> {
/** /**
* 获取指定节点所在树结构的全部树节点 <br> * 获取指定节点所在树结构的全部树节点 <br>
* 比如存在 a -> b -> c 的关系则输入 a/b/c 都将返回 a, b, c * 比如存在 a -&gt; b -&gt; c 的关系则输入 a/b/c 都将返回 a, b, c
* *
* @param key 指定节点的key * @param key 指定节点的key
* @return 节点 * @return 节点
@ -217,14 +218,14 @@ public interface ForestMap<K, V> extends Map<K, TreeEntry<K, V>> {
if (ObjectUtil.isNull(target)) { if (ObjectUtil.isNull(target)) {
return Collections.emptySet(); return Collections.emptySet();
} }
Set<TreeEntry<K, V>> results = CollUtil.newLinkedHashSet(target.getRoot()); final Set<TreeEntry<K, V>> results = CollUtil.newLinkedHashSet(target.getRoot());
CollUtil.addAll(results, target.getRoot().getChildren().values()); CollUtil.addAll(results, target.getRoot().getChildren().values());
return results; return results;
} }
/** /**
* 获取以指定节点作为叶子节点的树结构然后获取该树结构的根节点 <br> * 获取以指定节点作为叶子节点的树结构然后获取该树结构的根节点 <br>
* 比如存在 a -> b -> c 的关系则输入 a/b/c 都将返回 a * 比如存在 a -&gt; b -&gt; c 的关系则输入 a/b/c 都将返回 a
* *
* @param key 指定节点的key * @param key 指定节点的key
* @return 节点 * @return 节点
@ -237,7 +238,7 @@ public interface ForestMap<K, V> extends Map<K, TreeEntry<K, V>> {
/** /**
* 获取指定节点的直接父节点 <br> * 获取指定节点的直接父节点 <br>
* 比如若存在 a -> b -> c 的关系此时输入 a 将返回 null输入 b 将返回 a输入 c 将返回 b * 比如若存在 a -&gt; b -&gt; c 的关系此时输入 a 将返回 null输入 b 将返回 a输入 c 将返回 b
* *
* @param key 指定节点的key * @param key 指定节点的key
* @return 节点 * @return 节点
@ -251,7 +252,8 @@ public interface ForestMap<K, V> extends Map<K, TreeEntry<K, V>> {
/** /**
* 获取以指定节点作为叶子节点的树结构然后获取该树结构中指定节点的指定父节点 * 获取以指定节点作为叶子节点的树结构然后获取该树结构中指定节点的指定父节点
* *
* @param key 指定父节点的key * @param key 指定节点的key
* @param parentKey 指定父节点key
* @return 节点 * @return 节点
*/ */
default TreeEntry<K, V> getParentNode(K key, K parentKey) { default TreeEntry<K, V> getParentNode(K key, K parentKey) {
@ -290,7 +292,7 @@ public interface ForestMap<K, V> extends Map<K, TreeEntry<K, V>> {
/** /**
* 获取指定父节点直接关联的子节点 <br> * 获取指定父节点直接关联的子节点 <br>
* 比如若存在 a -> b -> c 的关系此时输入 b 将返回 c输入 a 将返回 b * 比如若存在 a -&gt; b -&gt; c 的关系此时输入 b 将返回 c输入 a 将返回 b
* *
* @param key key * @param key key
* @return 节点 * @return 节点
@ -304,7 +306,7 @@ public interface ForestMap<K, V> extends Map<K, TreeEntry<K, V>> {
/** /**
* 获取指定父节点的全部子节点 <br> * 获取指定父节点的全部子节点 <br>
* 比如若存在 a -> b -> c 的关系此时输入 b 将返回 c输入 a 将返回 bc * 比如若存在 a -&gt; b -&gt; c 的关系此时输入 b 将返回 c输入 a 将返回 bc
* *
* @param key key * @param key key
* @return 该节点的全部子节点 * @return 该节点的全部子节点

View File

@ -262,7 +262,8 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
*/ */
@Override @Override
public void linkNodes(K parentKey, K childKey, BiConsumer<TreeEntry<K, V>, TreeEntry<K, V>> consumer) { public void linkNodes(K parentKey, K childKey, BiConsumer<TreeEntry<K, V>, TreeEntry<K, V>> consumer) {
consumer = ObjectUtil.defaultIfNull(consumer, (parent, child) -> {}); consumer = ObjectUtil.defaultIfNull(consumer, (parent, child) -> {
});
final TreeEntryNode<K, V> parentNode = nodes.computeIfAbsent(parentKey, t -> new TreeEntryNode<>(null, t)); final TreeEntryNode<K, V> parentNode = nodes.computeIfAbsent(parentKey, t -> new TreeEntryNode<>(null, t));
TreeEntryNode<K, V> childNode = nodes.get(childKey); TreeEntryNode<K, V> childNode = nodes.get(childKey);
@ -472,7 +473,8 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
if (ObjectUtil.isNotNull(this.root)) { if (ObjectUtil.isNotNull(this.root)) {
return this.root; return this.root;
} else { } else {
this.root = traverseParentNodes(true, p -> {}, p -> !p.hasParent()); this.root = traverseParentNodes(true, p -> {
}, p -> !p.hasParent());
} }
return this.root; return this.root;
} }
@ -495,7 +497,8 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
*/ */
@Override @Override
public TreeEntryNode<K, V> getParent(K key) { public TreeEntryNode<K, V> getParent(K key) {
return traverseParentNodes(false, p -> {}, p -> p.equalsKey(key)); return traverseParentNodes(false, p -> {
}, p -> p.equalsKey(key));
} }
/** /**
@ -513,6 +516,7 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
* 指定key与当前节点的key是否相等 * 指定key与当前节点的key是否相等
* *
* @param key 要比较的key * @param key 要比较的key
* @return 是否key一致
*/ */
public boolean equalsKey(K key) { public boolean equalsKey(K key) {
return ObjectUtil.equal(getKey(), key); return ObjectUtil.equal(getKey(), key);
@ -594,7 +598,7 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
* @param key 子节点 * @param key 子节点
*/ */
void removeDeclaredChild(K key) { void removeDeclaredChild(K key) {
TreeEntryNode<K, V> child = children.get(key); final TreeEntryNode<K, V> child = children.get(key);
if (ObjectUtil.isNull(child)) { if (ObjectUtil.isNull(child)) {
return; return;
} }
@ -618,7 +622,8 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
*/ */
@Override @Override
public TreeEntryNode<K, V> getChild(K key) { public TreeEntryNode<K, V> getChild(K key) {
return traverseChildNodes(false, (i, c) -> {}, (i, c) -> c.equalsKey(key)); return traverseChildNodes(false, (i, c) -> {
}, (i, c) -> c.equalsKey(key));
} }
/** /**
@ -707,17 +712,21 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
*/ */
public static class EntryNodeWrapper<K, V, N extends TreeEntry<K, V>> implements Map.Entry<K, TreeEntry<K, V>> { public static class EntryNodeWrapper<K, V, N extends TreeEntry<K, V>> implements Map.Entry<K, TreeEntry<K, V>> {
private final N entryNode; private final N entryNode;
EntryNodeWrapper(N entryNode) { EntryNodeWrapper(N entryNode) {
this.entryNode = entryNode; this.entryNode = entryNode;
} }
@Override @Override
public K getKey() { public K getKey() {
return entryNode.getKey(); return entryNode.getKey();
} }
@Override @Override
public TreeEntry<K, V> getValue() { public TreeEntry<K, V> getValue() {
return entryNode; return entryNode;
} }
@Override @Override
public TreeEntry<K, V> setValue(TreeEntry<K, V> value) { public TreeEntry<K, V> setValue(TreeEntry<K, V> value) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();