public final class RestSdkUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
closeAndRelease(org.mule.runtime.api.streaming.CursorProvider<?> cursorProvider)
Closes the given
cursorProvider and releases all associated resources |
static void |
closeStream(Object stream)
|
static org.mule.runtime.api.metadata.TypedValue<String> |
consumeStringAndClose(Object stream,
org.mule.runtime.api.metadata.MediaType targetMediaType,
Charset targetCharset)
Consumes the contents of the given
stream as a String and closes it. |
static org.mule.runtime.api.metadata.TypedValue<String> |
consumeStringTransformAndClose(Object stream,
Charset sourceCharset,
org.mule.runtime.api.metadata.MediaType targetMediaType,
Charset targetCharset)
Consumes the contents of the given
stream as a String and closes it. |
static org.mule.runtime.api.metadata.TypedValue<InputStream> |
consumeToOfflineStreamAndClose(Object stream,
org.mule.runtime.api.metadata.MediaType targetMediaType,
Charset targetCharset)
Consumes the contents of the given
stream as a ByteArrayInputStream and closes it. |
static boolean |
containsIgnoreCase(String value,
String predicate) |
static org.mule.runtime.api.metadata.TypedValue<?> |
getTypedValueOrNull(Object o)
Creates a typed value for an object, or returns null if the objeect is null.
|
static boolean |
isBlank(CharSequence cs)
Checks if a CharSequence is empty (""), null or whitespace only.
|
static boolean |
isNotBlank(String v) |
static org.mule.metadata.api.model.MetadataType |
loadJsonSchema(ClassLoader classLoader,
String schemaPath,
org.mule.metadata.api.model.MetadataFormat metadataFormat) |
static org.mule.metadata.api.model.MetadataType |
loadXmlSchema(ClassLoader classLoader,
String schemaPath,
String qName) |
static String |
readSchema(ClassLoader classLoader,
String schemaPath) |
static Charset |
resolveCharset(Optional<org.mule.runtime.api.metadata.MediaType> mediaType,
org.mule.runtime.api.metadata.MediaType defaultMediaType) |
static List<org.mule.runtime.api.metadata.TypedValue<String>> |
toList(Iterator<org.mule.runtime.api.metadata.TypedValue<?>> iterator,
org.mule.runtime.api.metadata.MediaType mediaType,
org.mule.runtime.api.metadata.MediaType defaultMediaType)
Transform an iterator of TypedValue> into a list of TypedValue
|
static <T> org.mule.runtime.api.metadata.TypedValue<T> |
toPayloadTypedValue(org.mule.runtime.extension.api.runtime.operation.Result<T,?> result) |
static org.mule.runtime.api.metadata.TypedValue<String> |
toTypedValue(String value,
org.mule.runtime.api.metadata.MediaType mediaType,
Charset encoding) |
public static void closeAndRelease(org.mule.runtime.api.streaming.CursorProvider<?> cursorProvider)
cursorProvider and releases all associated resourcescursorProvider - a cursor providerpublic static void closeStream(Object stream)
stream which can be either a CursorProvider or an InputStream.
Null values or instances of other classes will be ignored.stream - a streampublic static org.mule.runtime.api.metadata.TypedValue<String> consumeStringAndClose(Object stream, org.mule.runtime.api.metadata.MediaType targetMediaType, Charset targetCharset)
stream as a String and closes it.
The stream can be either a CursorStreamProvider or an InputStream. IllegalArgumentException
will be thrown if the stream is an instance of any other class.
Notice that in the case of CursorStreamProvider, this method will close the provider meaning that it will no longer
be able to yield new cursors.
stream - a CursorStreamProvider or an InputStreamtargetCharset - the encoding to use when reading the String and that will be set to the TypedValuetargetMediaType - the media type that will be set to the TypedValueIllegalArgumentException - if stream is not of the expected types.public static org.mule.runtime.api.metadata.TypedValue<InputStream> consumeToOfflineStreamAndClose(Object stream, org.mule.runtime.api.metadata.MediaType targetMediaType, Charset targetCharset)
stream as a ByteArrayInputStream and closes it.
The stream can be either a CursorStreamProvider or an InputStream. IllegalArgumentException
will be thrown if the stream is an instance of any other class.
Notice that in the case of CursorStreamProvider, this method will close the provider meaning that it will no longer
be able to yield new cursors.
stream - a CursorStreamProvider or an InputStreamtargetCharset - the encoding to use when reading the String and that will be set to the TypedValuetargetMediaType - the media type that will be set to the TypedValueIllegalArgumentException - if stream is not of the expected types.public static org.mule.runtime.api.metadata.TypedValue<String> consumeStringTransformAndClose(Object stream, Charset sourceCharset, org.mule.runtime.api.metadata.MediaType targetMediaType, Charset targetCharset)
stream as a String and closes it.
The stream can be either a CursorStreamProvider or an InputStream. IllegalArgumentException
will be thrown if the stream is an instance of any other class.
Notice that in the case of CursorStreamProvider, this method will close the provider meaning that it will no longer
be able to yield new cursors.
stream - a CursorStreamProvider or an InputStreamsourceCharset - the encoding to use when reading the StringtargetCharset - the encoding that will be set to the TypedValuetargetMediaType - the media type that will be set to the TypedValueIllegalArgumentException - if stream is not of the expected types.public static org.mule.runtime.api.metadata.TypedValue<String> toTypedValue(String value, org.mule.runtime.api.metadata.MediaType mediaType, Charset encoding)
public static <T> org.mule.runtime.api.metadata.TypedValue<T> toPayloadTypedValue(org.mule.runtime.extension.api.runtime.operation.Result<T,?> result)
public static boolean isNotBlank(String v)
public static boolean isBlank(CharSequence cs)
Checks if a CharSequence is empty (""), null or whitespace only.
Whitespace is defined by Character.isWhitespace(char).
StringUtils.isBlank(null) = true
StringUtils.isBlank("") = true
StringUtils.isBlank(" ") = true
StringUtils.isBlank("bob") = false
StringUtils.isBlank(" bob ") = false
cs - the CharSequence to check, may be nulltrue if the CharSequence is null, empty or whitespace onlypublic static String readSchema(ClassLoader classLoader, String schemaPath)
public static org.mule.metadata.api.model.MetadataType loadXmlSchema(ClassLoader classLoader, String schemaPath, String qName)
public static org.mule.metadata.api.model.MetadataType loadJsonSchema(ClassLoader classLoader, String schemaPath, org.mule.metadata.api.model.MetadataFormat metadataFormat)
public static List<org.mule.runtime.api.metadata.TypedValue<String>> toList(Iterator<org.mule.runtime.api.metadata.TypedValue<?>> iterator, org.mule.runtime.api.metadata.MediaType mediaType, org.mule.runtime.api.metadata.MediaType defaultMediaType)
iterator - The iterator to consumemediaType - The primary source of the media type and charset. This is the media type for this specific iterator.defaultMediaType - Tee default source for the charset. The charset of this media type will be used if the primary one
does not contain one.public static Charset resolveCharset(Optional<org.mule.runtime.api.metadata.MediaType> mediaType, org.mule.runtime.api.metadata.MediaType defaultMediaType)
public static org.mule.runtime.api.metadata.TypedValue<?> getTypedValueOrNull(Object o)
Copyright © 2021. All rights reserved.