Compare commits

...

3 Commits

Author SHA1 Message Date
9ba77a2f04
[maven-release-plugin] prepare for next development iteration
All checks were successful
continuous-integration/drone/push Build is passing
2023-02-13 22:37:24 +03:00
fa914f949d
[maven-release-plugin] prepare release v.2.5.0 2023-02-13 22:37:23 +03:00
e5152c059d
Добавил новые методы проверки в Checker и Inspector 2023-02-13 22:36:52 +03:00
5 changed files with 33 additions and 8 deletions

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.struchkov.haiti</groupId> <groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti-dependencies</artifactId> <artifactId>haiti-dependencies</artifactId>
<version>2.5.0-SNAPSHOT</version> <version>2.6.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>haiti-exception</artifactId> <artifactId>haiti-exception</artifactId>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>dev.struchkov.haiti</groupId> <groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti-dependencies</artifactId> <artifactId>haiti-dependencies</artifactId>
<version>2.5.0-SNAPSHOT</version> <version>2.6.0-SNAPSHOT</version>
</parent> </parent>
<name>Haiti Utils</name> <name>Haiti Utils</name>

View File

@ -92,6 +92,14 @@ public final class Checker {
return EMPTY.equals(s); return EMPTY.equals(s);
} }
public static boolean checkNotBlank(String s) {
return checkNotNull(s) && !s.isBlank();
}
public static boolean checkBlank(String s) {
return checkNull(s) || s.isBlank();
}
public static boolean checkFalse(Boolean b) { public static boolean checkFalse(Boolean b) {
return b != null && !b; return b != null && !b;
} }

View File

@ -3,7 +3,9 @@ package dev.struchkov.haiti.utils;
import java.util.Collection; import java.util.Collection;
import java.util.function.Supplier; import java.util.function.Supplier;
import static dev.struchkov.haiti.utils.Checker.checkBlank;
import static dev.struchkov.haiti.utils.Checker.checkEmpty; import static dev.struchkov.haiti.utils.Checker.checkEmpty;
import static dev.struchkov.haiti.utils.Checker.checkNotBlank;
import static dev.struchkov.haiti.utils.Checker.checkNotEmpty; import static dev.struchkov.haiti.utils.Checker.checkNotEmpty;
import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Checker.checkNotNull;
import static dev.struchkov.haiti.utils.Checker.checkNull; import static dev.struchkov.haiti.utils.Checker.checkNull;
@ -106,9 +108,11 @@ public final class Inspector {
* @throws RuntimeException * @throws RuntimeException
*/ */
public static void isNotEmpty(Supplier<? extends RuntimeException> exception, Object... args) { public static void isNotEmpty(Supplier<? extends RuntimeException> exception, Object... args) {
if (checkEmpty(args)) { if (checkEmpty(args)) throw exception.get();
throw exception.get(); }
}
public static void isNotEmpty(String s, Supplier<? extends RuntimeException> exception) {
if (checkEmpty(s)) throw exception.get();
} }
/** /**
@ -121,6 +125,10 @@ public final class Inspector {
if (checkNotEmpty(collection)) throw exception.get(); if (checkNotEmpty(collection)) throw exception.get();
} }
public static void isEmpty(String s, Supplier<? extends RuntimeException> exception) {
if (checkNotEmpty(s)) throw exception.get();
}
/** /**
* Проверка массива на пустоту. Если массив не пустой и не null, то будет выбрашено исключение. * Проверка массива на пустоту. Если массив не пустой и не null, то будет выбрашено исключение.
* *
@ -131,10 +139,19 @@ public final class Inspector {
if (checkNotEmpty(args)) throw exception.get(); if (checkNotEmpty(args)) throw exception.get();
} }
public static void isNotBlank(String s, Supplier<? extends RuntimeException> exception) {
if (checkBlank(s)) throw exception.get();
}
public static void isBlank(String s, Supplier<? extends RuntimeException> exception) {
if (checkNotBlank(s)) throw exception.get();
}
/** /**
* Утилитарный класс. * Утилитарный класс.
*/ */
public static final class Utils { public static final class Utils {
private Utils() { private Utils() {
utilityClass(); utilityClass();
} }

View File

@ -4,7 +4,7 @@
<groupId>dev.struchkov.haiti</groupId> <groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti-dependencies</artifactId> <artifactId>haiti-dependencies</artifactId>
<version>2.5.0-SNAPSHOT</version> <version>2.6.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Haiti Framework</name> <name>Haiti Framework</name>
@ -50,12 +50,12 @@
<dependency> <dependency>
<groupId>dev.struchkov.haiti</groupId> <groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti-exception</artifactId> <artifactId>haiti-exception</artifactId>
<version>2.5.0-SNAPSHOT</version> <version>2.6.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>dev.struchkov.haiti</groupId> <groupId>dev.struchkov.haiti</groupId>
<artifactId>haiti-utils</artifactId> <artifactId>haiti-utils</artifactId>
<version>2.5.0-SNAPSHOT</version> <version>2.6.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>