Utils Class

  • java.lang.Object
    • com.microsoft.azure.management.resources.fluentcore.utils.Utils

public class Utils

Defines a few utilities.

Method Summary

Modifier and Type Method and Description
String createOdataFilterForTags(String tagName, String tagValue)

Creates an Odata filter string that can be used for filtering list results by tags.

Observable<byte[]> downloadFileAsync(String url, Retrofit retrofit)

Download a file asynchronously.

static<U extends Indexable> Observable<U> rootResource(Observable<Indexable> stream)

Gets an observable of U that emits only the root resource from a given observable of Indexable.

static<OutT, InT> PagedList<OutT> toPagedList(List<InT> list, final Func1<InT, OutT> mapper)

Converts the given list of a type to paged list of a different type.

boolean toPrimitiveBoolean(Boolean value)

Converts an object Boolean to a primitive boolean.

int toPrimitiveInt(Integer value)

Converts an object Integer to a primitive int.

int toPrimitiveInt(Long value)

Converts an object Long to a primitive int.

long toPrimitiveLong(Long value)

Converts an object Long to a primitive long.

Method Details

createOdataFilterForTags

public static String createOdataFilterForTags(String tagName, String tagValue)

Creates an Odata filter string that can be used for filtering list results by tags.

Parameters:

tagName - the name of the tag. If not provided, all resources will be returned.
tagValue - the value of the tag. If not provided, only tag name will be filtered.

Returns:

the Odata filter to pass into list methods

downloadFileAsync

public static Observable downloadFileAsync(String url, Retrofit retrofit)

Download a file asynchronously.

Parameters:

url - the URL pointing to the file
retrofit - the retrofit client

Returns:

an Observable pointing to the content of the file

rootResource

public static static Observable rootResource(Observable stream)

Gets an observable of U that emits only the root resource from a given observable of Indexable.

Parameters:

stream - the input observable of Indexable

Returns:

an observable that emits last item

toPagedList

public static static PagedList toPagedList(List list, final Func1 mapper)

Converts the given list of a type to paged list of a different type.

Parameters:

list - the list to convert to paged list
mapper - the mapper to map type in input list to output list

Returns:

the paged list

toPrimitiveBoolean

public static boolean toPrimitiveBoolean(Boolean value)

Converts an object Boolean to a primitive boolean.

Parameters:

value - the Boolean value

Returns:

false if the given Boolean value is null or false else true

toPrimitiveInt

public static int toPrimitiveInt(Integer value)

Converts an object Integer to a primitive int.

Parameters:

value - the Integer value

Returns:

0 if the given Integer value is null else integer value

toPrimitiveInt

public static int toPrimitiveInt(Long value)

Converts an object Long to a primitive int.

Parameters:

value - the Long value

Returns:

0 if the given Long value is null else integer value

toPrimitiveLong

public static long toPrimitiveLong(Long value)

Converts an object Long to a primitive long.

Parameters:

value - the Long value

Returns:

0 if the given Long value is null else long value

Applies to