java.lang.Object
com.predic8.membrane.core.openapi.util.Utils

public class Utils extends Object
  • Method Details

    • getComponentLocalNameFromRef

      public static String getComponentLocalNameFromRef(String ref)
    • stringToInputStream

      public static InputStream stringToInputStream(String s)
    • inputStreamToString

      public static String inputStreamToString(InputStream is) throws IOException
      Throws:
      IOException
    • isValidUUID

      public static boolean isValidUUID(String s)
    • isValidEMail

      public static boolean isValidEMail(String s)
    • isValidUri

      public static boolean isValidUri(String s)
    • isValidDate

      public static boolean isValidDate(String s)
    • isValidIp

      public static boolean isValidIp(String s)
    • isValidDateTime

      public static boolean isValidDateTime(String s)
    • convertToBigDecimal

      public static BigDecimal convertToBigDecimal(Object obj) throws NumberFormatException
      Converts an object to a BigDecimal.
      Parameters:
      obj - the object to be converted
      Returns:
      the converted BigDecimal
      Throws:
      NumberFormatException - if the conversion fails
    • joinByComma

      public static String joinByComma(Collection<String> l)
    • areThereErrors

      public static boolean areThereErrors(ValidationErrors ve)
    • getOpenapiValidatorRequest

      public static <T extends Body> Request<T> getOpenapiValidatorRequest(Exchange exc) throws IOException, jakarta.mail.internet.ParseException
      Throws:
      IOException
      jakarta.mail.internet.ParseException
    • getOpenapiValidatorResponse

      public static <T extends Body> Response<T> getOpenapiValidatorResponse(Exchange exc) throws jakarta.mail.internet.ParseException, IOException
      Throws:
      jakarta.mail.internet.ParseException
      IOException
    • getMediaTypeFromContentTypeHeader

      public static String getMediaTypeFromContentTypeHeader(String str)
      e.g. for header value "mediatype "application/json; charset=utf-8" this function should return "application/json" only.
    • setFieldIfNotNull

      public static <T> void setFieldIfNotNull(Map<String,T> m, String name, T v)
    • normalizeForId

      public static String normalizeForId(String s)
    • 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

      public static byte[] createErrorMessage(String msg)