public final class CoreUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> String |
arrayToString(T[] array,
Function<T,String> mapper)
Turns an array into a string mapping each element to a string and delimits them using a coma.
|
static String |
bomAwareToString(byte[] bytes,
String contentType)
Attempts to convert a byte stream into the properly encoded String.
|
static byte[] |
clone(byte[] source)
Creates a copy of the source byte array.
|
static int[] |
clone(int[] source)
Creates a copy of the source int array.
|
static <T> T[] |
clone(T[] source)
Creates a copy of the source array.
|
static <T> org.reactivestreams.Publisher<T> |
extractAndFetch(PagedResponse<T> page,
Context context,
BiFunction<String,Context,org.reactivestreams.Publisher<T>> content)
Extracts and combines the generic items from all the pages linked together.
|
static <T> T |
findFirstOfType(Object[] args,
Class<T> clazz)
Returns the first instance of the given class from an array of Objects.
|
static String |
getApplicationId(ClientOptions clientOptions,
HttpLogOptions logOptions)
Retrieves the application ID from either a
ClientOptions or HttpLogOptions. |
static Map<String,String> |
getProperties(String propertiesFileName)
Helper method that returns an immutable
Map of properties defined in propertiesFileName. |
static boolean |
isNullOrEmpty(CharSequence charSequence)
Checks if the character sequence is null or empty.
|
static boolean |
isNullOrEmpty(Collection<?> collection)
Checks if the collection is null or empty.
|
static boolean |
isNullOrEmpty(Map<?,?> map)
Checks if the map is null or empty.
|
static boolean |
isNullOrEmpty(Object[] array)
Checks if the array is null or empty.
|
public static byte[] clone(byte[] source)
source - Array to make copy ofpublic static int[] clone(int[] source)
source - Array to make copy ofpublic static <T> T[] clone(T[] source)
T - Generic representing the type of the source array.source - Array being copied.public static boolean isNullOrEmpty(Object[] array)
array - Array being checked for nullness or emptiness.public static boolean isNullOrEmpty(Collection<?> collection)
collection - Collection being checked for nullness or emptiness.public static boolean isNullOrEmpty(Map<?,?> map)
map - Map being checked for nullness or emptiness.public static boolean isNullOrEmpty(CharSequence charSequence)
charSequence - Character sequence being checked for nullness or emptiness.public static <T> String arrayToString(T[] array, Function<T,String> mapper)
T - Generic representing the type of the array.array - Array being formatted to a string.mapper - Function that maps each element to a string.public static <T> T findFirstOfType(Object[] args, Class<T> clazz)
T - Generic typeargs - Array of objects to search through to find the first instance of the given `clazz` type.clazz - The type trying to be found.public static <T> org.reactivestreams.Publisher<T> extractAndFetch(PagedResponse<T> page, Context context, BiFunction<String,Context,org.reactivestreams.Publisher<T>> content)
T - The type of the item being returned in the paged response.page - The paged response from server holding generic items.context - Metadata that is passed into the function that fetches the items from the next page.content - The function which fetches items from the next page.public static Map<String,String> getProperties(String propertiesFileName)
Map of properties defined in propertiesFileName.propertiesFileName - The file name defining the properties.Map.public static String bomAwareToString(byte[] bytes, String contentType)
This utility method will attempt to find the encoding for the String in this order.
charset in the Content-Type header.UTF-8.bytes - Byte array.contentType - Content-Type header value.public static String getApplicationId(ClientOptions clientOptions, HttpLogOptions logOptions)
ClientOptions or HttpLogOptions.
This method first checks clientOptions for having an application ID then logOptions, finally
returning null if neither are set.
clientOptions is checked first as logOptions application ID is deprecated.
clientOptions - The ClientOptions.logOptions - The HttpLogOptions.clientOptions or logOptions, if neither are set null.Copyright © 2021 Microsoft Corporation. All rights reserved.