Skip to content

Commit

Permalink
🐛 AssertState.notNull no stacktrace #26
Browse files Browse the repository at this point in the history
  • Loading branch information
trydofor committed Feb 21, 2024
1 parent a4cab83 commit 12364ff
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 51 deletions.
34 changes: 17 additions & 17 deletions src/main/java/pro/fessional/mirana/best/AssertArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void isTrue(boolean b, @NotNull String msg, Object... args) {

@Contract("false, _, _ -> fail")
public static void isTrue(boolean b, @NotNull CodeEnum code, Object... args) {
if (!b) throw new BadArgsException(false, code, args);
if (!b) throw new BadArgsException(code, args);
}

//
Expand All @@ -46,7 +46,7 @@ public static void isFalse(boolean b, @NotNull String msg, Object... args) {

@Contract("true, _, _ -> fail")
public static void isFalse(boolean b, @NotNull CodeEnum code, Object... args) {
if (b) throw new BadArgsException(false, code, args);
if (b) throw new BadArgsException(code, args);
}

//
Expand All @@ -62,7 +62,7 @@ public static void isNull(@Nullable Object b, @NotNull String msg, Object... arg

@Contract("!null, _, _ -> fail")
public static void isNull(@Nullable Object b, @NotNull CodeEnum code, Object... args) {
if (b != null) throw new BadArgsException(false, code, args);
if (b != null) throw new BadArgsException(code, args);
}

//
Expand All @@ -78,7 +78,7 @@ public static void notNull(@Nullable Object b, @NotNull String msg, Object... ar

@Contract("null, _, _ -> fail")
public static void notNull(@Nullable Object b, @NotNull CodeEnum code, Object... args) {
if (b == null) throw new BadArgsException(false, code, args);
if (b == null) throw new BadArgsException(code, args);
}

// ////
Expand All @@ -91,7 +91,7 @@ public static void isEmpty(@Nullable CharSequence c, @NotNull String msg, Object
}

public static void isEmpty(@Nullable CharSequence c, @NotNull CodeEnum code, Object... args) {
if (c != null && c.length() > 0) throw new BadArgsException(false, code, args);
if (c != null && c.length() > 0) throw new BadArgsException(code, args);
}

//
Expand All @@ -107,7 +107,7 @@ public static void notEmpty(@Nullable CharSequence c, @NotNull String msg, Objec

@Contract("null, _, _ -> fail")
public static void notEmpty(@Nullable CharSequence c, @NotNull CodeEnum code, Object... args) {
if (c == null || c.length() == 0) throw new BadArgsException(false, code, args);
if (c == null || c.length() == 0) throw new BadArgsException(code, args);
}

// ////
Expand All @@ -120,7 +120,7 @@ public static void isEmpty(@Nullable Collection<?> c, @NotNull String msg, Objec
}

public static void isEmpty(@Nullable Collection<?> c, @NotNull CodeEnum code, Object... args) {
if (c != null && !c.isEmpty()) throw new BadArgsException(false, code, args);
if (c != null && !c.isEmpty()) throw new BadArgsException(code, args);
}

//
Expand All @@ -136,7 +136,7 @@ public static void notEmpty(@Nullable Collection<?> c, @NotNull String msg, Obje

@Contract("null, _, _ -> fail")
public static void notEmpty(@Nullable Collection<?> c, @NotNull CodeEnum code, Object... args) {
if (c == null || c.isEmpty()) throw new BadArgsException(false, code, args);
if (c == null || c.isEmpty()) throw new BadArgsException(code, args);
}

// ////
Expand All @@ -149,7 +149,7 @@ public static void isEmpty(@Nullable Map<?, ?> c, @NotNull String msg, Object...
}

public static void isEmpty(@Nullable Map<?, ?> c, @NotNull CodeEnum code, Object... args) {
if (c != null && !c.isEmpty()) throw new BadArgsException(false, code, args);
if (c != null && !c.isEmpty()) throw new BadArgsException(code, args);
}

//
Expand All @@ -165,7 +165,7 @@ public static void notEmpty(@Nullable Map<?, ?> c, @NotNull String msg, Object..

@Contract("null, _, _ -> fail")
public static void notEmpty(@Nullable Map<?, ?> c, @NotNull CodeEnum code, Object... args) {
if (c == null || c.isEmpty()) throw new BadArgsException(false, code, args);
if (c == null || c.isEmpty()) throw new BadArgsException(code, args);
}

// ////
Expand All @@ -178,7 +178,7 @@ public static void isEmpty(@Nullable Object[] c, @NotNull String msg, Object...
}

public static void isEmpty(@Nullable Object[] c, @NotNull CodeEnum code, Object... args) {
if (c != null && c.length > 0) throw new BadArgsException(false, code, args);
if (c != null && c.length > 0) throw new BadArgsException(code, args);
}

//
Expand All @@ -194,7 +194,7 @@ public static void notEmpty(@Nullable Object[] c, @NotNull String msg, Object...

@Contract("null, _, _ -> fail")
public static void notEmpty(@Nullable Object[] c, @NotNull CodeEnum code, Object... args) {
if (c == null || c.length == 0) throw new BadArgsException(false, code, args);
if (c == null || c.length == 0) throw new BadArgsException(code, args);
}

//
Expand All @@ -210,7 +210,7 @@ public static <T extends Comparable<T>> void aEqb(@Nullable T a, @Nullable T b,

public static <T extends Comparable<T>> void aEqb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null && b == null) return;
if (a == null || !a.equals(b)) throw new BadArgsException(false, code, args);
if (a == null || !a.equals(b)) throw new BadArgsException(code, args);
}

//
Expand All @@ -226,7 +226,7 @@ public static <T extends Comparable<T>> void aGeb(@Nullable T a, @Nullable T b,

public static <T extends Comparable<T>> void aGeb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null && b == null) return;
if (a == null || b == null || a.compareTo(b) < 0) throw new BadArgsException(false, code, args);
if (a == null || b == null || a.compareTo(b) < 0) throw new BadArgsException(code, args);
}

//
Expand All @@ -239,7 +239,7 @@ public static <T extends Comparable<T>> void aGtb(@Nullable T a, @Nullable T b,
}

public static <T extends Comparable<T>> void aGtb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null || b == null || a.compareTo(b) <= 0) throw new BadArgsException(false, code, args);
if (a == null || b == null || a.compareTo(b) <= 0) throw new BadArgsException(code, args);
}

//
Expand All @@ -255,7 +255,7 @@ public static <T extends Comparable<T>> void aLeb(@Nullable T a, @Nullable T b,

public static <T extends Comparable<T>> void aLeb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null && b == null) return;
if (a == null || b == null || a.compareTo(b) > 0) throw new BadArgsException(false, code, args);
if (a == null || b == null || a.compareTo(b) > 0) throw new BadArgsException(code, args);
}

//
Expand All @@ -268,6 +268,6 @@ public static <T extends Comparable<T>> void aLtb(@Nullable T a, @Nullable T b,
}

public static <T extends Comparable<T>> void aLtb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null || b == null || a.compareTo(b) >= 0) throw new BadArgsException(false, code, args);
if (a == null || b == null || a.compareTo(b) >= 0) throw new BadArgsException(code, args);
}
}
34 changes: 17 additions & 17 deletions src/main/java/pro/fessional/mirana/best/AssertMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void isTrue(boolean b, @NotNull String msg, Object... args) {

@Contract("false, _, _ -> fail")
public static void isTrue(boolean b, @NotNull CodeEnum code, Object... args) {
if (!b) throw new MessageException(false, code, args);
if (!b) throw new MessageException(code, args);
}

//
Expand All @@ -46,7 +46,7 @@ public static void isFalse(boolean b, @NotNull String msg, Object... args) {

@Contract("true, _, _ -> fail")
public static void isFalse(boolean b, @NotNull CodeEnum code, Object... args) {
if (b) throw new MessageException(false, code, args);
if (b) throw new MessageException(code, args);
}

// ////
Expand All @@ -62,7 +62,7 @@ public static void isNull(@Nullable Object b, @NotNull String msg, Object... arg

@Contract("!null, _, _ -> fail")
public static void isNull(@Nullable Object b, @NotNull CodeEnum code, Object... args) {
if (b != null) throw new MessageException(false, code, args);
if (b != null) throw new MessageException(code, args);
}

//
Expand All @@ -78,7 +78,7 @@ public static void notNull(@Nullable Object b, @NotNull String msg, Object... ar

@Contract("null, _, _ -> fail")
public static void notNull(@Nullable Object b, @NotNull CodeEnum code, Object... args) {
if (b == null) throw new MessageException(false, code, args);
if (b == null) throw new MessageException(code, args);
}

// ////
Expand All @@ -91,7 +91,7 @@ public static void isEmpty(@Nullable CharSequence c, @NotNull String msg, Object
}

public static void isEmpty(@Nullable CharSequence c, @NotNull CodeEnum code, Object... args) {
if (c != null && c.length() > 0) throw new MessageException(false, code, args);
if (c != null && c.length() > 0) throw new MessageException(code, args);
}

//
Expand All @@ -107,7 +107,7 @@ public static void notEmpty(@Nullable CharSequence c, @NotNull String msg, Objec

@Contract("null, _, _ -> fail")
public static void notEmpty(@Nullable CharSequence c, @NotNull CodeEnum code, Object... args) {
if (c == null || c.length() == 0) throw new MessageException(false, code, args);
if (c == null || c.length() == 0) throw new MessageException(code, args);
}

// ////
Expand All @@ -120,7 +120,7 @@ public static void isEmpty(@Nullable Collection<?> c, @NotNull String msg, Objec
}

public static void isEmpty(@Nullable Collection<?> c, @NotNull CodeEnum code, Object... args) {
if (c != null && !c.isEmpty()) throw new MessageException(false, code, args);
if (c != null && !c.isEmpty()) throw new MessageException(code, args);
}

//
Expand All @@ -136,7 +136,7 @@ public static void notEmpty(@Nullable Collection<?> c, @NotNull String msg, Obje

@Contract("null, _, _ -> fail")
public static void notEmpty(@Nullable Collection<?> c, @NotNull CodeEnum code, Object... args) {
if (c == null || c.isEmpty()) throw new MessageException(false, code, args);
if (c == null || c.isEmpty()) throw new MessageException(code, args);
}

// ////
Expand All @@ -149,7 +149,7 @@ public static void isEmpty(@Nullable Map<?, ?> c, @NotNull String msg, Object...
}

public static void isEmpty(@Nullable Map<?, ?> c, @NotNull CodeEnum code, Object... args) {
if (c != null && !c.isEmpty()) throw new MessageException(false, code, args);
if (c != null && !c.isEmpty()) throw new MessageException(code, args);
}

//
Expand All @@ -165,7 +165,7 @@ public static void notEmpty(@Nullable Map<?, ?> c, @NotNull String msg, Object..

@Contract("null, _, _ -> fail")
public static void notEmpty(@Nullable Map<?, ?> c, @NotNull CodeEnum code, Object... args) {
if (c == null || c.isEmpty()) throw new MessageException(false, code, args);
if (c == null || c.isEmpty()) throw new MessageException(code, args);
}

// ////
Expand All @@ -178,7 +178,7 @@ public static void isEmpty(@Nullable Object[] c, @NotNull String msg, Object...
}

public static void isEmpty(@Nullable Object[] c, @NotNull CodeEnum code, Object... args) {
if (c != null && c.length > 0) throw new MessageException(false, code, args);
if (c != null && c.length > 0) throw new MessageException(code, args);
}

//
Expand All @@ -194,7 +194,7 @@ public static void notEmpty(@Nullable Object[] c, @NotNull String msg, Object...

@Contract("null, _, _ -> fail")
public static void notEmpty(@Nullable Object[] c, @NotNull CodeEnum code, Object... args) {
if (c == null || c.length == 0) throw new MessageException(false, code, args);
if (c == null || c.length == 0) throw new MessageException(code, args);
}


Expand All @@ -211,7 +211,7 @@ public static <T extends Comparable<T>> void aEqb(@Nullable T a, @Nullable T b,

public static <T extends Comparable<T>> void aEqb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null && b == null) return;
if (a == null || !a.equals(b)) throw new MessageException(false, code, args);
if (a == null || !a.equals(b)) throw new MessageException(code, args);
}

//
Expand All @@ -227,7 +227,7 @@ public static <T extends Comparable<T>> void aGeb(@Nullable T a, @Nullable T b,

public static <T extends Comparable<T>> void aGeb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null && b == null) return;
if (a == null || b == null || a.compareTo(b) < 0) throw new MessageException(false, code, args);
if (a == null || b == null || a.compareTo(b) < 0) throw new MessageException(code, args);
}

//
Expand All @@ -240,7 +240,7 @@ public static <T extends Comparable<T>> void aGtb(@Nullable T a, @Nullable T b,
}

public static <T extends Comparable<T>> void aGtb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null || b == null || a.compareTo(b) <= 0) throw new MessageException(false, code, args);
if (a == null || b == null || a.compareTo(b) <= 0) throw new MessageException(code, args);
}

//
Expand All @@ -256,7 +256,7 @@ public static <T extends Comparable<T>> void aLeb(@Nullable T a, @Nullable T b,

public static <T extends Comparable<T>> void aLeb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null && b == null) return;
if (a == null || b == null || a.compareTo(b) > 0) throw new MessageException(false, code, args);
if (a == null || b == null || a.compareTo(b) > 0) throw new MessageException(code, args);
}

//
Expand All @@ -269,6 +269,6 @@ public static <T extends Comparable<T>> void aLtb(@Nullable T a, @Nullable T b,
}

public static <T extends Comparable<T>> void aLtb(@Nullable T a, @Nullable T b, @NotNull CodeEnum code, Object... args) {
if (a == null || b == null || a.compareTo(b) >= 0) throw new MessageException(false, code, args);
if (a == null || b == null || a.compareTo(b) >= 0) throw new MessageException(code, args);
}
}
Loading

0 comments on commit 12364ff

Please sign in to comment.