ref[protocol]: 重构protocol

This commit is contained in:
jaysunxiao committed 2021-10-15 14:02:58 +08:00
1 parent e9e2158b33
commit edfbbb97e9
5 files changed
+63 -65

No files matched your search

@@ -50,12 +50,12 @@ public abstract class GenerateProtocolDocument {
* // byte的包装类型 * // byte的包装类型
* // 优先使用基础类型,包装类型会有装箱拆箱 * // 优先使用基础类型,包装类型会有装箱拆箱
*/ */
private static Map<Short, Pair<String, Map<String, String>>> tempProtocolDocumentMap = new HashMap<>(); private static Map<Short, Pair<String, Map<String, String>>> protocolDocumentMap = new HashMap<>();
public static void clear() { public static void clear() {
tempProtocolDocumentMap.clear(); protocolDocumentMap.clear();
tempProtocolDocumentMap = null; protocolDocumentMap = null;
} }
@@ -63,9 +63,9 @@ public abstract class GenerateProtocolDocument {
* 此方法仅在生成协议的时候调用,一旦运行,不能调用 * 此方法仅在生成协议的时候调用,一旦运行,不能调用
*/ */
public static Pair<String, Map<String, String>> getProtocolDocument(short protocolId) { public static Pair<String, Map<String, String>> getProtocolDocument(short protocolId) {
AssertionUtils.notNull(tempProtocolDocumentMap, "[{}]已经初始完成,初始化完成过后不能调用getProtocolDocument", GenerateProtocolDocument.class.getSimpleName()); AssertionUtils.notNull(protocolDocumentMap, "[{}]已经初始完成,初始化完成过后不能调用getProtocolDocument", GenerateProtocolDocument.class.getSimpleName());
var protocolDocument = tempProtocolDocumentMap.get(protocolId); var protocolDocument = protocolDocumentMap.get(protocolId);
if (protocolDocument == null) { if (protocolDocument == null) {
return new Pair<>(StringUtils.EMPTY, Collections.emptyMap()); return new Pair<>(StringUtils.EMPTY, Collections.emptyMap());
} }
@@ -74,7 +74,7 @@ public abstract class GenerateProtocolDocument {
public static void initProtocolDocument(List<IProtocolRegistration> protocolRegistrations) { public static void initProtocolDocument(List<IProtocolRegistration> protocolRegistrations) {
AssertionUtils.notNull(tempProtocolDocumentMap, "[{}]已经初始完成,初始化完成过后不能调用initProtocolDocument", GenerateProtocolDocument.class.getSimpleName()); AssertionUtils.notNull(protocolDocumentMap, "[{}]已经初始完成,初始化完成过后不能调用initProtocolDocument", GenerateProtocolDocument.class.getSimpleName());
// 文件的注释生成 // 文件的注释生成
var proAbsFile = new File(FileUtils.getProAbsPath()); var proAbsFile = new File(FileUtils.getProAbsPath());
@@ -181,7 +181,7 @@ public abstract class GenerateProtocolDocument {
docBuilder = new StringBuilder(); docBuilder = new StringBuilder();
} }
tempProtocolDocumentMap.put(protocolRegistration.protocolId(), new Pair<>(docTitle, docFieldMap)); protocolDocumentMap.put(protocolRegistration.protocolId(), new Pair<>(docTitle, docFieldMap));
} }
} }
@@ -31,21 +31,21 @@ import java.util.stream.Collectors;
public abstract class GenerateProtocolPath { public abstract class GenerateProtocolPath {
// 临时变量,启动完成就会销毁,协议生成的路径 // 临时变量,启动完成就会销毁,协议生成的路径
private static Map<Short, String> tempProtocolPathMap = new HashMap<>(); private static Map<Short, String> protocolPathMap = new HashMap<>();
public static void clear() { public static void clear() {
tempProtocolPathMap.clear(); protocolPathMap.clear();
tempProtocolPathMap = null; protocolPathMap = null;
} }
/** /**
* 获取协议生成的路径 * 获取协议生成的路径
*/ */
public static String getProtocolPath(short protocolId) { public static String getProtocolPath(short protocolId) {
AssertionUtils.notNull(tempProtocolPathMap, "[{}]已经初始完成,初始化完成过后不能调用getProtocolPath", GenerateProtocolPath.class.getSimpleName()); AssertionUtils.notNull(protocolPathMap, "[{}]已经初始完成,初始化完成过后不能调用getProtocolPath", GenerateProtocolPath.class.getSimpleName());
var protocolPath = tempProtocolPathMap.get(protocolId); var protocolPath = protocolPathMap.get(protocolId);
if (StringUtils.isBlank(protocolPath)) { if (StringUtils.isBlank(protocolPath)) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
@@ -66,7 +66,7 @@ public abstract class GenerateProtocolPath {
* @param protocolRegistrations 需要解析的路径 * @param protocolRegistrations 需要解析的路径
*/ */
public static void initProtocolPath(List<IProtocolRegistration> protocolRegistrations) { public static void initProtocolPath(List<IProtocolRegistration> protocolRegistrations) {
AssertionUtils.notNull(tempProtocolPathMap, "[{}]已经初始完成,初始化完成过后不能调用initProtocolPath", GenerateProtocolPath.class.getSimpleName()); AssertionUtils.notNull(protocolPathMap, "[{}]已经初始完成,初始化完成过后不能调用initProtocolPath", GenerateProtocolPath.class.getSimpleName());
// 将需要生成的协议的路径添加到多叉树中 // 将需要生成的协议的路径添加到多叉树中
var protocolPathTree = new GeneralTree<IProtocolRegistration>(); var protocolPathTree = new GeneralTree<IProtocolRegistration>();
@@ -113,7 +113,7 @@ public abstract class GenerateProtocolPath {
.split(StringUtils.PERIOD_REGEX)) .split(StringUtils.PERIOD_REGEX))
.filter(it -> !StringUtils.isBlank(it)) .filter(it -> !StringUtils.isBlank(it))
.toArray(); .toArray();
tempProtocolPathMap.put(child.getData().protocolId(), StringUtils.joinWith(StringUtils.PERIOD, splits)); protocolPathMap.put(child.getData().protocolId(), StringUtils.joinWith(StringUtils.PERIOD, splits));
} }
} }
@@ -48,48 +48,48 @@ public class ProtocolAnalysis {
// 临时变量,启动完成就会销毁,协议名称保留字符,即协议的名称不能用以下名称命名 // 临时变量,启动完成就会销毁,协议名称保留字符,即协议的名称不能用以下名称命名
private static Set<String> tempProtocolReserved = Set.of("Buffer", "ByteBuf", "ByteBuffer", "LittleEndianByteBuffer", "NormalByteBuffer" private static Set<String> protocolReserved = Set.of("Buffer", "ByteBuf", "ByteBuffer", "LittleEndianByteBuffer", "NormalByteBuffer"
, "IPacket", "IProtocolRegistration", "ProtocolManager", "IFieldRegistration" , "IPacket", "IProtocolRegistration", "ProtocolManager", "IFieldRegistration"
, "ByteBufUtils", "ArrayUtils", "CollectionUtils" , "ByteBufUtils", "ArrayUtils", "CollectionUtils"
, "Boolean", "Byte", "Short", "Integer", "Long", "Float", "Double", "String", "Character", "Object" , "Boolean", "Byte", "Short", "Integer", "Long", "Float", "Double", "String", "Character", "Object"
, "Collections", "Iterator", "List", "ArrayList", "Map", "HashMap", "Set", "HashSet"); , "Collections", "Iterator", "List", "ArrayList", "Map", "HashMap", "Set", "HashSet");
// 临时变量,启动完成就会销毁,是一个基本类型序列化器 // 临时变量,启动完成就会销毁,是一个基本类型序列化器
private static Map<Class<?>, ISerializer> tempBaseSerializerMap = new HashMap<>(); private static Map<Class<?>, ISerializer> baseSerializerMap = new HashMap<>();
// 临时变量,启动完成就会销毁,协议Id对应的Class类 // 临时变量,启动完成就会销毁,协议Id对应的Class类
private static Map<Short, Class<?>> tempProtocolClassMap = new HashMap<>(MAX_PROTOCOL_NUM); private static Map<Short, Class<?>> protocolClassMap = new HashMap<>(MAX_PROTOCOL_NUM);
// 临时变量,启动完成就会销毁,协议下包含的子协议,只包含一层子协议 // 临时变量,启动完成就会销毁,协议下包含的子协议,只包含一层子协议
private static Map<Short, Set<Short>> tempSubProtocolIdMap = new HashMap<>(MAX_PROTOCOL_NUM); private static Map<Short, Set<Short>> subProtocolIdMap = new HashMap<>(MAX_PROTOCOL_NUM);
static { static {
// 初始化基础类型序列化器 // 初始化基础类型序列化器
tempBaseSerializerMap.put(boolean.class, BooleanSerializer.INSTANCE); baseSerializerMap.put(boolean.class, BooleanSerializer.INSTANCE);
tempBaseSerializerMap.put(Boolean.class, BooleanSerializer.INSTANCE); baseSerializerMap.put(Boolean.class, BooleanSerializer.INSTANCE);
tempBaseSerializerMap.put(byte.class, ByteSerializer.INSTANCE); baseSerializerMap.put(byte.class, ByteSerializer.INSTANCE);
tempBaseSerializerMap.put(Byte.class, ByteSerializer.INSTANCE); baseSerializerMap.put(Byte.class, ByteSerializer.INSTANCE);
tempBaseSerializerMap.put(short.class, ShortSerializer.INSTANCE); baseSerializerMap.put(short.class, ShortSerializer.INSTANCE);
tempBaseSerializerMap.put(Short.class, ShortSerializer.INSTANCE); baseSerializerMap.put(Short.class, ShortSerializer.INSTANCE);
tempBaseSerializerMap.put(int.class, IntSerializer.INSTANCE); baseSerializerMap.put(int.class, IntSerializer.INSTANCE);
tempBaseSerializerMap.put(Integer.class, IntSerializer.INSTANCE); baseSerializerMap.put(Integer.class, IntSerializer.INSTANCE);
tempBaseSerializerMap.put(long.class, LongSerializer.INSTANCE); baseSerializerMap.put(long.class, LongSerializer.INSTANCE);
tempBaseSerializerMap.put(Long.class, LongSerializer.INSTANCE); baseSerializerMap.put(Long.class, LongSerializer.INSTANCE);
tempBaseSerializerMap.put(float.class, FloatSerializer.INSTANCE); baseSerializerMap.put(float.class, FloatSerializer.INSTANCE);
tempBaseSerializerMap.put(Float.class, FloatSerializer.INSTANCE); baseSerializerMap.put(Float.class, FloatSerializer.INSTANCE);
tempBaseSerializerMap.put(double.class, DoubleSerializer.INSTANCE); baseSerializerMap.put(double.class, DoubleSerializer.INSTANCE);
tempBaseSerializerMap.put(Double.class, DoubleSerializer.INSTANCE); baseSerializerMap.put(Double.class, DoubleSerializer.INSTANCE);
tempBaseSerializerMap.put(char.class, CharSerializer.INSTANCE); baseSerializerMap.put(char.class, CharSerializer.INSTANCE);
tempBaseSerializerMap.put(Character.class, CharSerializer.INSTANCE); baseSerializerMap.put(Character.class, CharSerializer.INSTANCE);
tempBaseSerializerMap.put(String.class, StringSerializer.INSTANCE); baseSerializerMap.put(String.class, StringSerializer.INSTANCE);
} }
public static synchronized void analyze(Set<Class<?>> protocolClassSet, GenerateOperation generateOperation) { public static synchronized void analyze(Set<Class<?>> protocolClassSet, GenerateOperation generateOperation) {
AssertionUtils.notNull(tempSubProtocolIdMap, "[{}]已经初始完成,请不要重复初始化", ProtocolManager.class.getSimpleName()); AssertionUtils.notNull(subProtocolIdMap, "[{}]已经初始完成,请不要重复初始化", ProtocolManager.class.getSimpleName());
try { try {
for (var protocolClass : protocolClassSet) { for (var protocolClass : protocolClassSet) {
var id = getProtocolIdByClass(protocolClass); var id = getProtocolIdByClass(protocolClass);
var previous = tempProtocolClassMap.put(id, protocolClass); var previous = protocolClassMap.put(id, protocolClass);
if (previous != null) { if (previous != null) {
throw new RunException("[{}][{}]协议号[protocolId:{}]重复", protocolClass.getCanonicalName(), previous.getCanonicalName(), id); throw new RunException("[{}][{}]协议号[protocolId:{}]重复", protocolClass.getCanonicalName(), previous.getCanonicalName(), id);
} }
@@ -118,7 +118,7 @@ public class ProtocolAnalysis {
public static synchronized void analyze(XmlProtocols xmlProtocols, GenerateOperation generateOperation) { public static synchronized void analyze(XmlProtocols xmlProtocols, GenerateOperation generateOperation) {
AssertionUtils.notNull(tempSubProtocolIdMap, "[{}]已经初始完成,请不要重复初始化", ProtocolManager.class.getSimpleName()); AssertionUtils.notNull(subProtocolIdMap, "[{}]已经初始完成,请不要重复初始化", ProtocolManager.class.getSimpleName());
try { try {
var enhanceList = new ArrayList<IProtocolRegistration>(); var enhanceList = new ArrayList<IProtocolRegistration>();
@@ -145,7 +145,7 @@ public class ProtocolAnalysis {
// 协议号是否和id是否相等 // 协议号是否和id是否相等
AssertionUtils.isTrue(packet.protocolId() == id, "[class:{}]协议序列号[{}]和协议文件里的协议序列号不相等", clazz.getCanonicalName(), PROTOCOL_ID); AssertionUtils.isTrue(packet.protocolId() == id, "[class:{}]协议序列号[{}]和协议文件里的协议序列号不相等", clazz.getCanonicalName(), PROTOCOL_ID);
var previous = tempProtocolClassMap.put(id, clazz); var previous = protocolClassMap.put(id, clazz);
if (previous != null) { if (previous != null) {
throw new RunException("[{}][{}]协议号[protocolId:{}]重复", clazz.getCanonicalName(), previous.getCanonicalName(), id); throw new RunException("[{}][{}]协议号[protocolId:{}]重复", clazz.getCanonicalName(), previous.getCanonicalName(), id);
} }
@@ -156,7 +156,7 @@ public class ProtocolAnalysis {
var module = modules[moduleDefinition.getId()]; var module = modules[moduleDefinition.getId()];
for (var protocolDefinition : moduleDefinition.getProtocols()) { for (var protocolDefinition : moduleDefinition.getProtocols()) {
var id = protocolDefinition.getId(); var id = protocolDefinition.getId();
var clazz = tempProtocolClassMap.get(id); var clazz = protocolClassMap.get(id);
try { try {
var registration = parseProtocolRegistration(clazz, module); var registration = parseProtocolRegistration(clazz, module);
if (protocolDefinition.isEnhance()) { if (protocolDefinition.isEnhance()) {
@@ -210,13 +210,13 @@ public class ProtocolAnalysis {
} }
private static void enhanceProtocolAfter() { private static void enhanceProtocolAfter() {
tempSubProtocolIdMap.clear(); subProtocolIdMap.clear();
tempSubProtocolIdMap = null; subProtocolIdMap = null;
tempProtocolReserved = null; protocolReserved = null;
tempBaseSerializerMap.clear(); baseSerializerMap.clear();
tempBaseSerializerMap = null; baseSerializerMap = null;
GenerateProtocolDocument.clear(); GenerateProtocolDocument.clear();
GenerateProtocolPath.clear(); GenerateProtocolPath.clear();
@@ -298,7 +298,7 @@ public class ProtocolAnalysis {
throw new RunException("[class:{}]和[class:{}]协议名称重复,协议不能含有重复的名称", protocolClass.getCanonicalName(), allProtocolNameMap.get(protocolName).getCanonicalName()); throw new RunException("[class:{}]和[class:{}]协议名称重复,协议不能含有重复的名称", protocolClass.getCanonicalName(), allProtocolNameMap.get(protocolName).getCanonicalName());
} }
if (tempProtocolReserved.stream().anyMatch(it -> it.equalsIgnoreCase(protocolName))) { if (protocolReserved.stream().anyMatch(it -> it.equalsIgnoreCase(protocolName))) {
throw new RunException("协议的名称[class:{}]不能是保留名称[{}]", protocolClass.getCanonicalName(), protocolName); throw new RunException("协议的名称[class:{}]不能是保留名称[{}]", protocolClass.getCanonicalName(), protocolName);
} }
@@ -307,7 +307,7 @@ public class ProtocolAnalysis {
// 检查循环协议 // 检查循环协议
for (var protocolEntry : tempSubProtocolIdMap.entrySet()) { for (var protocolEntry : subProtocolIdMap.entrySet()) {
var protocolId = protocolEntry.getKey(); var protocolId = protocolEntry.getKey();
var subProtocolSet = protocolEntry.getValue(); var subProtocolSet = protocolEntry.getValue();
if (subProtocolSet.contains(protocolId)) { if (subProtocolSet.contains(protocolId)) {
@@ -320,7 +320,7 @@ public class ProtocolAnalysis {
} }
private static void checkSubProtocol(Class<?> clazz, short id, Class<?> subClass) { private static void checkSubProtocol(Class<?> clazz, short id, Class<?> subClass) {
var registerProtocolClass = tempProtocolClassMap.get(id); var registerProtocolClass = protocolClassMap.get(id);
if (registerProtocolClass == null || !registerProtocolClass.equals(subClass)) { if (registerProtocolClass == null || !registerProtocolClass.equals(subClass)) {
throw new RunException("协议[{}]的子协议[{}][{}]没有注册", clazz.getCanonicalName(), id, subClass.getCanonicalName()); throw new RunException("协议[{}]的子协议[{}][{}]没有注册", clazz.getCanonicalName(), id, subClass.getCanonicalName());
} }
@@ -373,7 +373,7 @@ public class ProtocolAnalysis {
private static IFieldRegistration toRegistration(Class<?> clazz, Field field) { private static IFieldRegistration toRegistration(Class<?> clazz, Field field) {
Class<?> fieldTypeClazz = field.getType(); Class<?> fieldTypeClazz = field.getType();
ISerializer serializer = tempBaseSerializerMap.get(fieldTypeClazz); ISerializer serializer = baseSerializerMap.get(fieldTypeClazz);
// 是一个基本类型变量 // 是一个基本类型变量
if (serializer != null) { if (serializer != null) {
@@ -449,7 +449,7 @@ public class ProtocolAnalysis {
// 是一个协议引用变量 // 是一个协议引用变量
var referenceProtocolId = getProtocolIdByClass(field.getType()); var referenceProtocolId = getProtocolIdByClass(field.getType());
checkSubProtocol(clazz, referenceProtocolId, field.getType()); checkSubProtocol(clazz, referenceProtocolId, field.getType());
tempSubProtocolIdMap.computeIfAbsent(getProtocolIdByClass(clazz), it -> new HashSet<>()).add(referenceProtocolId); subProtocolIdMap.computeIfAbsent(getProtocolIdByClass(clazz), it -> new HashSet<>()).add(referenceProtocolId);
return ObjectProtocolField.valueOf(referenceProtocolId); return ObjectProtocolField.valueOf(referenceProtocolId);
} }
} }
@@ -474,7 +474,7 @@ public class ProtocolAnalysis {
} }
} else if (type instanceof Class) { } else if (type instanceof Class) {
Class<?> clazz = ((Class<?>) type); Class<?> clazz = ((Class<?>) type);
ISerializer serializer = tempBaseSerializerMap.get(clazz); ISerializer serializer = baseSerializerMap.get(clazz);
if (serializer != null) { if (serializer != null) {
// 基础类型 // 基础类型
return BaseField.valueOf(serializer); return BaseField.valueOf(serializer);
@@ -487,7 +487,7 @@ public class ProtocolAnalysis {
// 是一个协议引用变量 // 是一个协议引用变量
var referenceProtocolId = getProtocolIdByClass(clazz); var referenceProtocolId = getProtocolIdByClass(clazz);
checkSubProtocol(clazz, referenceProtocolId, clazz); checkSubProtocol(clazz, referenceProtocolId, clazz);
tempSubProtocolIdMap.computeIfAbsent(getProtocolIdByClass(currentProtocolClass), it -> new HashSet<>()).add(referenceProtocolId); subProtocolIdMap.computeIfAbsent(getProtocolIdByClass(currentProtocolClass), it -> new HashSet<>()).add(referenceProtocolId);
return ObjectProtocolField.valueOf(referenceProtocolId); return ObjectProtocolField.valueOf(referenceProtocolId);
} }
} }
@@ -505,20 +505,20 @@ public class ProtocolAnalysis {
* 此方法仅在生成协议的时候调用,一旦运行,不能调用 * 此方法仅在生成协议的时候调用,一旦运行,不能调用
*/ */
public static Set<Short> getAllSubProtocolIds(short protocolId) { public static Set<Short> getAllSubProtocolIds(short protocolId) {
AssertionUtils.notNull(tempSubProtocolIdMap, "[{}]已经初始完成,初始化完成过后不能调用getAllSubProtocolIds", ProtocolAnalysis.class.getSimpleName()); AssertionUtils.notNull(subProtocolIdMap, "[{}]已经初始完成,初始化完成过后不能调用getAllSubProtocolIds", ProtocolAnalysis.class.getSimpleName());
if (!tempSubProtocolIdMap.containsKey(protocolId)) { if (!subProtocolIdMap.containsKey(protocolId)) {
return Collections.emptySet(); return Collections.emptySet();
} }
var protocolClass = protocols[protocolId].protocolConstructor().getDeclaringClass(); var protocolClass = protocols[protocolId].protocolConstructor().getDeclaringClass();
var queue = new LinkedList<>(tempSubProtocolIdMap.get(protocolId)); var queue = new LinkedList<>(subProtocolIdMap.get(protocolId));
var allSubProtocolIdSet = new HashSet<>(queue); var allSubProtocolIdSet = new HashSet<>(queue);
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
var firstSubProtocolId = queue.poll(); var firstSubProtocolId = queue.poll();
if (tempSubProtocolIdMap.containsKey(firstSubProtocolId)) { if (subProtocolIdMap.containsKey(firstSubProtocolId)) {
for (var subClassId : tempSubProtocolIdMap.get(firstSubProtocolId)) { for (var subClassId : subProtocolIdMap.get(firstSubProtocolId)) {
if (subClassId == protocolId) { if (subClassId == protocolId) {
throw new RunException("[class:{}]在下层协议[class:{}]包含循环引用协议[class:{}]", protocolClass.getSimpleName(), protocols[firstSubProtocolId].protocolConstructor().getDeclaringClass(), protocolClass.getSimpleName()); throw new RunException("[class:{}]在下层协议[class:{}]包含循环引用协议[class:{}]", protocolClass.getSimpleName(), protocols[firstSubProtocolId].protocolConstructor().getDeclaringClass(), protocolClass.getSimpleName());
} }
@@ -113,7 +113,6 @@ public abstract class ClassUtils {
// 获取下一个元素,如果是jar://得到的结果大概是:jar:file:/C:/Users/ibm/.m2/repository/junit/junit/4.12/junit-4.12.jar!/org/junit // 获取下一个元素,如果是jar://得到的结果大概是:jar:file:/C:/Users/ibm/.m2/repository/junit/junit/4.12/junit-4.12.jar!/org/junit
URL url = urlEnumeration.nextElement(); URL url = urlEnumeration.nextElement();
String protocol = url.getProtocol(); String protocol = url.getProtocol();
System.out.println(url);
if (StringUtils.isBlank(protocol)) { if (StringUtils.isBlank(protocol)) {
continue; continue;
} }
@@ -74,7 +74,6 @@ public abstract class FileUtils {
* @return 搜索到的文件 * @return 搜索到的文件
*/ */
private static File searchFileInProject(File file, String fileName) { private static File searchFileInProject(File file, String fileName) {
// System.out.println(file.getName());
if (file.isFile() && file.getName().equals(fileName)) { if (file.isFile() && file.getName().equals(fileName)) {
return file; return file;
} }
@@ -84,8 +83,8 @@ public abstract class FileUtils {
return null; return null;
} }
for (File temp : files) { for (var f : files) {
File result = searchFileInProject(temp, fileName); File result = searchFileInProject(f, fileName);
if (result == null) { if (result == null) {
continue; continue;
} }
@@ -106,9 +105,9 @@ public abstract class FileUtils {
Queue<File> queue = new LinkedList<>(); Queue<File> queue = new LinkedList<>();
queue.add(fileOrDirectory); queue.add(fileOrDirectory);
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
File file = queue.poll(); var file = queue.poll();
if (file.isDirectory()) { if (file.isDirectory()) {
for (File f : file.listFiles()) { for (var f : file.listFiles()) {
queue.offer(f); queue.offer(f);
} }
continue; continue;
@@ -201,9 +200,9 @@ public abstract class FileUtils {
*/ */
public static void deleteFile(final File file) { public static void deleteFile(final File file) {
if (file.isDirectory()) { if (file.isDirectory()) {
File[] files = file.listFiles(); var files = file.listFiles();
if (files != null) { if (files != null) {
for (File subFile : files) { for (var subFile : files) {
deleteFile(subFile); deleteFile(subFile);
} }
} }