Навел порядок в утилитарном модуле

This commit is contained in:
Struchkov Mark 2022-07-26 08:44:28 +03:00
parent ae8391ccb8
commit e8867426ad
10 changed files with 50 additions and 37 deletions

View File

@ -6,7 +6,7 @@
<groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti-bom</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<packaging>pom</packaging>
<name>Haiti BOM</name>
@ -30,7 +30,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<haiti.ver>1.1.0</haiti.ver>
<haiti.ver>1.2.0</haiti.ver>
<haiti.exception.ver>${haiti.ver}</haiti.exception.ver>
<haiti.context.ver>${haiti.ver}</haiti.context.ver>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<artifactId>haiti-context</artifactId>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<artifactId>haiti-core</artifactId>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<artifactId>haiti-exception</artifactId>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<artifactId>haiti-filter</artifactId>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</parent>
<name>Haiti Utils</name>

View File

@ -0,0 +1,37 @@
package dev.struchkov.haiti.utils;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
public final class CollectionUtils {
private CollectionUtils() {
utilityClass();
}
public static <T> List<T> toList(T... t) {
return Arrays.stream(t).collect(Collectors.toList());
}
public static <T> Collection<T> toCollection(T... t) {
return Arrays.stream(t).collect(Collectors.toList());
}
public static <T> Collection<T> toCollection(Collection<T> collection, T... t) {
return Stream.concat(
collection.stream(), Arrays.stream(t)
).collect(Collectors.toList());
}
public static <T> Collection<T> toCollection(Collection<T> collectionOne, Collection<T> collectionTwo) {
return Stream.concat(
collectionOne.stream(), collectionTwo.stream()
).collect(Collectors.toList());
}
}

View File

@ -7,10 +7,6 @@ import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
import static dev.struchkov.haiti.utils.Inspector.isNotNull;
@ -145,24 +141,4 @@ public class ObjectUtils {
&& method.getName().toLowerCase().endsWith(fieldName.toLowerCase());
}
public static <T> List<T> toList(T... t) {
return Arrays.stream(t).collect(Collectors.toList());
}
public static <T> Collection<T> toCollect(T... t) {
return Arrays.stream(t).collect(Collectors.toList());
}
public static <T> Collection<T> toCollect(Collection<T> collection, T... t) {
return Stream.concat(
collection.stream(), Arrays.stream(t)
).collect(Collectors.toList());
}
public static <T> Collection<T> toCollect(Collection<T> collectionOne, Collection<T> collectionTwo) {
return Stream.concat(
collectionOne.stream(), collectionTwo.stream()
).collect(Collectors.toList());
}
}

View File

@ -10,7 +10,7 @@ import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
public final class Parser {
private static Pattern URL_PARSE;
private static Pattern urlParse;
private Parser() {
utilityClass();
@ -29,10 +29,10 @@ public final class Parser {
}
private static Pattern getUrlParse() {
if (checkNull(URL_PARSE)) {
URL_PARSE = Pattern.compile("(https?://)([^:^/]*)(:\\d*)?(.*)?");
if (checkNull(urlParse)) {
urlParse = Pattern.compile("(https?://)([^:^/]*)(:\\d*)?(.*)?");
}
return URL_PARSE;
return urlParse;
}
}

View File

@ -6,7 +6,7 @@
<groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<packaging>pom</packaging>
<name>Haiti Framework</name>
@ -39,7 +39,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<haiti.ver>1.1.0</haiti.ver>
<haiti.ver>1.2.0</haiti.ver>
<haiti.bom.ver>${haiti.ver}</haiti.bom.ver>
<haiti.exception.ver>${haiti.ver}</haiti.exception.ver>