mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-20 06:24:12 +00:00
@@ -485,38 +485,5 @@ public abstract class StringUtils {
|
||||
return Character.isWhitespace(ch) || STOP_WORD.contains(ch);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param str 待匹配字符串
|
||||
* @param matchStr 匹配的后缀
|
||||
* @return 是否成功匹配后缀
|
||||
*/
|
||||
public static boolean suffixMatch(final String str,final String matchStr){
|
||||
if(matchStr.length()>str.length())
|
||||
return false;
|
||||
for(int i=0;i<matchStr.length();i++){
|
||||
if(str.charAt(str.length()-1-i)!=matchStr.charAt(matchStr.length()-1-i))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*把String数组展开成一个大的字符串
|
||||
* @param strings
|
||||
* @return
|
||||
*/
|
||||
public static String stringArrayToString(final String[] strings){
|
||||
StringBuilder stringBuilder=new StringBuilder();
|
||||
stringBuilder.append('[');
|
||||
for(var i=0;i<strings.length;i++){
|
||||
if(i!=0){
|
||||
stringBuilder.append(',');
|
||||
}
|
||||
stringBuilder.append(StringUtils.format("[{}]",i+1));
|
||||
stringBuilder.append(strings[i]);
|
||||
}
|
||||
stringBuilder.append(']');
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,11 +260,14 @@ public class StorageManager implements IStorageManager {
|
||||
packageSearchPath = packageSearchPath.replaceAll("//", "/");
|
||||
try {
|
||||
for(var resource :resourcePatternResolver.getResources(packageSearchPath)){
|
||||
if(StringUtils.suffixMatch(resource.getFilename(), ResourceEnum.CSV.getType())
|
||||
||StringUtils.suffixMatch(resource.getFilename(), ResourceEnum.EXCEL_XLS.getType())
|
||||
||StringUtils.suffixMatch(resource.getFilename(), ResourceEnum.EXCEL_XLSX.getType())
|
||||
||StringUtils.suffixMatch(resource.getFilename(), ResourceEnum.JSON.getType()))
|
||||
var resourceFilename=resource.getFilename();
|
||||
if(resourceFilename.endsWith(ResourceEnum.CSV.getType())
|
||||
|| resourceFilename.endsWith(ResourceEnum.EXCEL_XLS.getType())
|
||||
|| resourceFilename.endsWith(ResourceEnum.EXCEL_XLSX.getType())
|
||||
|| resourceFilename.endsWith(ResourceEnum.JSON.getType())){
|
||||
resourceDefSet.add(new ResourceDef(clazz,resource));
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
@@ -275,11 +278,13 @@ public class StorageManager implements IStorageManager {
|
||||
packageSearchPath = StringUtils.format("{}/{}.*", resourceLocation, clazz.getSimpleName());
|
||||
packageSearchPath = packageSearchPath.replaceAll("//", "/");
|
||||
for(var resource :resourcePatternResolver.getResources(packageSearchPath)){
|
||||
if(StringUtils.suffixMatch(resource.getFilename(), ResourceEnum.CSV.getType())
|
||||
||StringUtils.suffixMatch(resource.getFilename(), ResourceEnum.EXCEL_XLS.getType())
|
||||
||StringUtils.suffixMatch(resource.getFilename(), ResourceEnum.EXCEL_XLSX.getType())
|
||||
||StringUtils.suffixMatch(resource.getFilename(), ResourceEnum.JSON.getType()))
|
||||
var resourceFilename=resource.getFilename();
|
||||
if(resourceFilename.endsWith(ResourceEnum.CSV.getType())
|
||||
|| resourceFilename.endsWith(ResourceEnum.EXCEL_XLS.getType())
|
||||
|| resourceFilename.endsWith(ResourceEnum.EXCEL_XLSX.getType())
|
||||
|| resourceFilename.endsWith(ResourceEnum.JSON.getType())){
|
||||
resourceDefSet.add(new ResourceDef(clazz,resource));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,10 +295,11 @@ public class StorageManager implements IStorageManager {
|
||||
var resourceNames=new String[resourceDefSet.size()];
|
||||
var index=0;
|
||||
for(var resourceDef:resourceDefSet){
|
||||
resourceNames[index++]=resourceDef.getResource().getFile().getAbsolutePath();
|
||||
resourceNames[index++]=StringUtils.format("[{}]{}",index,resourceDef.getResource().getFile().getAbsolutePath());
|
||||
}
|
||||
|
||||
throw new RuntimeException(StringUtils.format("资源类[class:{}]找到重复的配置文件{}", clazz.getSimpleName(),StringUtils.stringArrayToString(resourceNames)));
|
||||
StringJoiner stringJoiner=new StringJoiner(",","[","]");
|
||||
Arrays.stream(resourceNames).forEach(stringJoiner::add);
|
||||
throw new RuntimeException(StringUtils.format("资源类[class:{}]找到重复的配置文件{}", clazz.getSimpleName(),stringJoiner.toString()));
|
||||
} else {
|
||||
return ((ResourceDef)(resourceDefSet.toArray()[0])).getResource();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user