Compare commits
3 Commits
5a06d32523
...
9ba77a2f04
Author | SHA1 | Date | |
---|---|---|---|
9ba77a2f04 | |||
fa914f949d | |||
e5152c059d |
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.haiti</groupId>
|
||||
<artifactId>haiti-dependencies</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<version>2.6.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>haiti-exception</artifactId>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>dev.struchkov.haiti</groupId>
|
||||
<artifactId>haiti-dependencies</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<version>2.6.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<name>Haiti Utils</name>
|
||||
|
@ -92,6 +92,14 @@ public final class Checker {
|
||||
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) {
|
||||
return b != null && !b;
|
||||
}
|
||||
|
@ -3,7 +3,9 @@ package dev.struchkov.haiti.utils;
|
||||
import java.util.Collection;
|
||||
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.checkNotBlank;
|
||||
import static dev.struchkov.haiti.utils.Checker.checkNotEmpty;
|
||||
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
|
||||
import static dev.struchkov.haiti.utils.Checker.checkNull;
|
||||
@ -106,9 +108,11 @@ public final class Inspector {
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static void isNotEmpty(Supplier<? extends RuntimeException> exception, Object... args) {
|
||||
if (checkEmpty(args)) {
|
||||
throw exception.get();
|
||||
if (checkEmpty(args)) 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();
|
||||
}
|
||||
|
||||
public static void isEmpty(String s, Supplier<? extends RuntimeException> exception) {
|
||||
if (checkNotEmpty(s)) throw exception.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка массива на пустоту. Если массив не пустой и не null, то будет выбрашено исключение.
|
||||
*
|
||||
@ -131,10 +139,19 @@ public final class Inspector {
|
||||
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 {
|
||||
|
||||
private Utils() {
|
||||
utilityClass();
|
||||
}
|
||||
|
6
pom.xml
6
pom.xml
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>dev.struchkov.haiti</groupId>
|
||||
<artifactId>haiti-dependencies</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<version>2.6.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Haiti Framework</name>
|
||||
@ -50,12 +50,12 @@
|
||||
<dependency>
|
||||
<groupId>dev.struchkov.haiti</groupId>
|
||||
<artifactId>haiti-exception</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<version>2.6.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.struchkov.haiti</groupId>
|
||||
<artifactId>haiti-utils</artifactId>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<version>2.6.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
Loading…
Reference in New Issue
Block a user