This commit is contained in:
2019-04-29 01:08:52 +08:00
parent ff240dd3ea
commit a255c52cc0
3 changed files with 54 additions and 10 deletions

View File

@@ -38,11 +38,13 @@ public final class FileKit {
/** /**
* 拷贝文件/文件目录 * 拷贝文件/文件目录
* @param source * @param source 源文件目录
* @param target * @param target 目标目录
* @param linkPath
*/ */
public static void copyFiles(File source, File target, String linkPath) { private static void copyFiles(File source, File target) {
copyFiles(source, target, "");
}
private static void copyFiles(File source, File target, String linkPath) {
if (source.isDirectory()){ if (source.isDirectory()){
final String _linkPath = linkPath + File.separator+ source.getName(); final String _linkPath = linkPath + File.separator+ source.getName();
asList(source.listFiles()).forEach(f->{ asList(source.listFiles()).forEach(f->{

View File

@@ -1,7 +1,7 @@
package net.tccn.base; package net.tccn.base;
import java.util.Objects; import java.lang.reflect.Array;
import java.util.Set; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -10,17 +10,59 @@ import java.util.stream.Stream;
*/ */
public class Liangs { public class Liangs {
public static <T> Set<T> streamConcat(Stream<T> ... streams) { /**
* 将集合数组合并到一个Set<T> 集合中
* @param <T> 泛型
* @param streams 集合数组
* @return
*/
public static <T> Stream<T> concat(Stream<T> ... streams) {
Stream<T> stream = Stream.empty(); Stream<T> stream = Stream.empty();
for (int i = 0; i < streams.length; i++) { for (int i = 0; i < streams.length; i++) {
stream = Stream.concat(stream, streams[i]); stream = Stream.concat(stream, streams[i]);
} }
return stream.collect(Collectors.toSet()); return stream;
} }
/**
* 将字符串第一个字母转大写
* @param str 待转换字符串
* @return
*/
public static String toUpperCaseFirst(String str) { public static String toUpperCaseFirst(String str) {
Objects.requireNonNull(str); Objects.requireNonNull(str);
return str.substring(0, 1).toUpperCase() + str.substring(1); return str.substring(0, 1).toUpperCase() + str.substring(1);
} }
/**
* 转化集合为数组,带泛型支持
* @param values 集合
* @param <T> 泛型
* @return
*/
public static <T> T[] toArray(Collection<T> values) {
if (values == null || values.size() == 0)
throw new UnsupportedOperationException("Not supported yet.");
Class<?> clazz = null;
for (T entity : values) {
clazz = entity.getClass();
break;
}
return values.toArray((T[]) Array.newInstance(clazz, values.size()));
}
/**
* 转化集合为数组,带泛型支持
* @param values 集合
* @param <T> 泛型
* @return
*/
public static <T> T[] toArray(Stream<T> values) {
if (values == null || values.count() == 0)
throw new UnsupportedOperationException("Not supported yet.");
List<T> list = values.collect(Collectors.toList());
return toArray(list);
}
} }

View File

@@ -399,7 +399,7 @@ public final class MetaKit {
Set<String> allAlias; Set<String> allAlias;
if (!all) { if (!all) {
allAlias = Liangs.streamConcat( allAlias = Liangs.concat(
metaService.getFilters().stream().map(f -> { metaService.getFilters().stream().map(f -> {
String col = (String) f.getName(); String col = (String) f.getName();
String alias = col.split("[.]")[0]; String alias = col.split("[.]")[0];
@@ -408,7 +408,7 @@ public final class MetaKit {
metaService.getExports().stream().map(x -> x.get("col").split("[.]")[0]), metaService.getExports().stream().map(x -> x.get("col").split("[.]")[0]),
metaService.getShows().stream().map(x -> x.get("col").split("[.]")[0])/*, todo: xxx metaService.getShows().stream().map(x -> x.get("col").split("[.]")[0])/*, todo: xxx
metaService.getEdits().stream().map(x -> x.split("[.]")[0])*/ metaService.getEdits().stream().map(x -> x.split("[.]")[0])*/
); ).collect(Collectors.toSet());
} else { } else {
allAlias = new HashSet<>(); allAlias = new HashSet<>();