Skip to content

Commit

Permalink
feat: added shorthand for BigDecimal, Long, Boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
melistik committed Feb 18, 2020
1 parent 1af85ee commit 6c50c5d
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.rocketbase.commons.util;

import java.math.BigDecimal;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
Expand All @@ -26,6 +27,36 @@ public static String notNull(String value) {
return notNull(value, "");
}

/**
* return false when value is null
*/
public static Boolean notNull(Boolean value) {
if (value == null) {
return false;
}
return value;
}

/**
* return 0 when value is null
*/
public static Long notNull(Long value) {
if (value == null) {
return 0l;
}
return value;
}

/**
* return BigDecimal.ZERO when value is null
*/
public static BigDecimal notNull(BigDecimal value) {
if (value == null) {
return BigDecimal.ZERO;
}
return value;
}

/**
* in case of null value return's new ArrayList
*/
Expand Down

0 comments on commit 6c50c5d

Please sign in to comment.