Class APIUtil
- java.lang.Object
-
- com.github.m0nk3y2k4.thetvdb.internal.util.APIUtil
-
public final class APIUtil extends Object
General utility class providing a collection of useful little helper methods.
Contains various non-specific helper methods used to process common tasks like checking for (non)empty Strings or converting values into a String representation.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
hasNoValue(String... strings)
Checks if at least one of the given strings is an empty character sequencestatic boolean
hasValue(String... strings)
Checks if all of the given Strings are non-empty character sequencesstatic String
prettyPrint(com.fasterxml.jackson.databind.JsonNode obj)
Serializes the given JSON object as String using a pretty print output with indentation to produce an easy-to-read String representation of the JSON object.static <T> String
toString(Supplier<T> valueSupplier)
Converts the value returned by the givenvalueSupplier
into a new String.static <T> String
toString(Supplier<T> valueSupplier, String nullDefault)
Converts the value returned by the givenvalueSupplier
into a new String.
-
-
-
Method Detail
-
hasValue
public static boolean hasValue(String... strings)
Checks if all of the given Strings are non-empty character sequences- Parameters:
strings
- The strings to check- Returns:
Boolean.FALSE
if at least one of the given Strings isnull
or contains only blanks.
-
hasNoValue
public static boolean hasNoValue(String... strings)
Checks if at least one of the given strings is an empty character sequence- Parameters:
strings
- The strings to check- Returns:
Boolean.TRUE
if at least one of the given Strings isnull
or contains only blanks.
-
prettyPrint
public static String prettyPrint(@Nonnull com.fasterxml.jackson.databind.JsonNode obj) throws com.fasterxml.jackson.core.JsonProcessingException
Serializes the given JSON object as String using a pretty print output with indentation to produce an easy-to-read String representation of the JSON object.- Parameters:
obj
- The JSON object to be printed in a pretty fashion- Returns:
- Easy-to-read String representation of the given JSON object
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- If an error occurred while processing the JSON object
-
toString
public static <T> String toString(Supplier<T> valueSupplier)
Converts the value returned by the givenvalueSupplier
into a new String. The output depends on the actual type argument <T> of the given supplier. If the supplied value is unconvertible an empty String will be returned instead.- Type Parameters:
T
- The type of results supplied by the given supplier- Parameters:
valueSupplier
- The supplier whoseSupplier.get()
output should be converted into a String- Returns:
- Supplier output value converted to a String representation or an empty String
-
toString
public static <T> String toString(Supplier<T> valueSupplier, String nullDefault)
Converts the value returned by the givenvalueSupplier
into a new String. The output depends on the actual type argument <T> of the given supplier. If the supplied value is unconvertible the value ofnullDefault
will be returned instead.- Type Parameters:
T
- The type of results supplied by the given supplier- Parameters:
valueSupplier
- The supplier whoseSupplier.get()
output should be converted into a StringnullDefault
- The fallback default value to be returned by this method if the supplied value could not be converted- Returns:
- Supplier output value converted to a String representation or
nullDefault
-
-