Class ParserUtil
java.lang.Object
com.thanlinardos.spring_enterprise_library.parse.utils.ParserUtil
A utility class for safely parsing various data types from strings and objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetPathParameterFromLocationURI(jakarta.ws.rs.core.Response response) Extracts the last path parameter from the Location URI in a JAX-RS Response.static BooleansafeParseBoolean(String value) Safely parses a String to a Boolean.static DoublesafeParseDouble(String str) Safely parses a String to a Double.static FloatsafeParseFloat(String str) Safely parses a String to a Float.static IntegersafeParseInteger(String str) Safely parses a String to an Integer.safeParseListString(List<Object> list) Safely parses a List of Objects to a List of Strings.static LongsafeParseLong(String str) Safely parses a String to a Long.static OffsetDateTimeSafely parses a String to an OffsetDateTime.Safely converts an Object to an Optional UUID.static StringSafely converts an Object to a String.static UUIDSafely converts an Object to a UUID.static UUIDsafeParseUUID(String str) Safely parses a String to a UUID.
-
Constructor Details
-
ParserUtil
public ParserUtil()
-
-
Method Details
-
safeParseInteger
-
safeParseFloat
-
safeParseDouble
-
safeParseOffsetDateTime
Safely parses a String to an OffsetDateTime.- Parameters:
str- the String to parse.- Returns:
- the parsed OffsetDateTime, or null if parsing fails.
-
safeParseUUID
-
safeParseBoolean
-
safeParseString
-
safeParseUUID
-
safeParseOptionalUUID
-
safeParseListString
Safely parses a List of Objects to a List of Strings.- Parameters:
list- the List of Objects to parse.- Returns:
- a List of Strings, with each Object converted to a String. If an Object is null, it will be represented as null in the resulting List.
-
safeParseLong
-
getPathParameterFromLocationURI
Extracts the last path parameter from the Location URI in a JAX-RS Response.- Parameters:
response- the JAX-RS Response containing the Location URI.- Returns:
- the last path parameter as a String, or null if the path is empty.
-