Class GetUtils
java.lang.Object
com.igormaznitsa.meta.common.utils.GetUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TensureNonNull(T value) Get value if it is not null.static <T> TensureNonNull(T value, T defaultValue) Get value and ensure that the value is not nullstatic StringensureNonNullAndNonEmpty(String value, String dflt) Get non-null non-empty string.static StringensureNonNullStr(String value) Ensure that a string will not be null.static <T> TfindFirstNonNull(T... objects) Find the first non-null value in an array and return that.
-
Constructor Details
-
GetUtils
private GetUtils()
-
-
Method Details
-
ensureNonNull
public static <T> T ensureNonNull(T value, T defaultValue) Get value and ensure that the value is not null- Type Parameters:
T- type of value- Parameters:
value- the valuedefaultValue- the default value to be returned if the value is null- Returns:
- not null value
- Throws:
AssertionError- if both the value and the default value are null- Since:
- 1.0
-
ensureNonNull
public static <T> T ensureNonNull(T value) Get value if it is not null.- Type Parameters:
T- type of value- Parameters:
value- the value- Returns:
- the value if it is not null
- Throws:
AssertionError- if the value is null- Since:
- 1.0
-
findFirstNonNull
public static <T> T findFirstNonNull(T... objects) Find the first non-null value in an array and return that.- Type Parameters:
T- type of value- Parameters:
objects- array to find value- Returns:
- the first non-null value from the array
- Throws:
AssertionError- if the array is null or it doesn't contain a non-null value- Since:
- 1.0
-
ensureNonNullAndNonEmpty
Get non-null non-empty string.- Parameters:
value- a base stringdflt- default string to be provided if value is null or empty- Returns:
- non-nullable non-empty string
- Since:
- 1.1.1
-
ensureNonNullStr
-