Class Utils
java.lang.Object
com.predic8.membrane.core.openapi.util.Utils
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic BigDecimalConverts an object to a BigDecimal.static byte[]createErrorMessage(String msg) static Stringstatic Stringe.g.static InputStreamgetResourceAsStream(Object obj, String location) Safe alternative of Class.getResourceAsStream() that can handle spaces in the base path.static Stringstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanisValidUri(String s) static booleanstatic Stringstatic Stringstatic <T> voidsetFieldIfNotNull(Map<String, T> m, String name, T v) static InputStream
-
Method Details
-
getComponentLocalNameFromRef
-
stringToInputStream
-
inputStreamToString
- Throws:
IOException
-
isValidUUID
-
isValidEMail
-
isValidUri
-
isValidDate
-
isValidIp
-
isValidDateTime
-
convertToBigDecimal
Converts an object to a BigDecimal.- Parameters:
obj- the object to be converted- Returns:
- the converted BigDecimal
- Throws:
NumberFormatException- if the conversion fails
-
joinByComma
-
areThereErrors
-
getOpenapiValidatorRequest
public static <T extends Body> Request<T> getOpenapiValidatorRequest(Exchange exc) throws IOException, jakarta.mail.internet.ParseException - Throws:
IOExceptionjakarta.mail.internet.ParseException
-
getOpenapiValidatorResponse
public static <T extends Body> Response<T> getOpenapiValidatorResponse(Exchange exc) throws jakarta.mail.internet.ParseException, IOException - Throws:
jakarta.mail.internet.ParseExceptionIOException
-
getMediaTypeFromContentTypeHeader
e.g. for header value "mediatype "application/json; charset=utf-8" this function should return "application/json" only. -
setFieldIfNotNull
-
normalizeForId
-
getResourceAsStream
public static InputStream getResourceAsStream(Object obj, String location) throws FileNotFoundException Safe alternative of Class.getResourceAsStream() that can handle spaces in the base path.- Parameters:
obj- Object reference of caller. Usually set to `this` of the caller.location- Location of the resource. E.g. /foo- Returns:
- InputStream of resource.
- Throws:
FileNotFoundException- when resource not found.
-
createErrorMessage
-