public class Utils extends Object
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkResponseStatus(org.json.JSONObject jsonResponse)
This does generic processing of processed JSON objects to ensure that the API returned ok: true
|
static String |
generateRandomString(int length)
Generates a random alphanumeric String of the length specified
|
static void |
processInputFileField(com.mashape.unirest.request.body.MultipartBody request,
String fieldName,
InputFile inputFile)
Adds an input file to a request, with the given field name.
|
static void |
processNotificationContent(com.mashape.unirest.request.body.MultipartBody multipartBody,
NotificationOptions notificationOptions)
This does generic processing of NotificationOptions objects when sending a request to the API
|
static void |
processReplyContent(com.mashape.unirest.request.body.MultipartBody multipartBody,
ReplyingOptions replyingOptions)
This does generic processing of ReplyingOptions objects when sending a request to the API
|
static org.json.JSONObject |
processResponse(com.mashape.unirest.http.HttpResponse<String> response)
This does some generic processing on HttpResponse objects returned by the Telegram Bot API
|
static void |
validateNotNull(Object... objects)
Generic method for ensuring an array of objects aren't null, if any object is null a NullPointerException is
thrown
|
static void |
validateNotNull(Object object)
Generic method for ensuring an object isn't null, if it is null a NullPointerException is thrown
|
static void |
validateNotNull(Object object,
String message)
Generic method for ensuring an object isn't null, if it is null a NullPointerException is thrown
|
public static String generateRandomString(int length)
length - The required length of the Stringpublic static org.json.JSONObject processResponse(com.mashape.unirest.http.HttpResponse<String> response)
response - The HttpResponse object returned by Unirest from the Telegram Bot API callpublic static void processReplyContent(com.mashape.unirest.request.body.MultipartBody multipartBody,
ReplyingOptions replyingOptions)
multipartBody - The MultipartBody that the ReplyingOptions content should be appended toreplyingOptions - The ReplyingOptions that were used in this requestpublic static void processNotificationContent(com.mashape.unirest.request.body.MultipartBody multipartBody,
NotificationOptions notificationOptions)
multipartBody - The MultipartBody that the NotificationOptions content should be appended tonotificationOptions - The NotificationOptions that were used in this requestpublic static boolean checkResponseStatus(org.json.JSONObject jsonResponse)
jsonResponse - The JSONObject that you want to checkpublic static void processInputFileField(com.mashape.unirest.request.body.MultipartBody request,
String fieldName,
InputFile inputFile)
request - The request to be added to.fieldName - The name of the field.inputFile - The input file.public static void validateNotNull(Object object)
object - The object you want to check isn't nullpublic static void validateNotNull(Object object, String message)
object - The object you want to check isn't nullmessage - The message you want the NullPointerException to have in the case that the object is nullpublic static void validateNotNull(Object... objects)
objects - The objects that you want to ensure aren't nullCopyright © 2017. All rights reserved.