本文整理汇总了Java中com.google.gson.JsonObject.isJsonNull方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.isJsonNull方法的具体用法?Java JsonObject.isJsonNull怎么用?Java JsonObject.isJsonNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gson.JsonObject
的用法示例。
在下文中一共展示了JsonObject.isJsonNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: overrideDefaultSettings
import com.google.gson.JsonObject; //导入方法依赖的package包/类
/**
* Overrides default setting with the settings fetched fron the community.
*
* @param clientSettings Local settings to be used.
* @param serverSettingJson Settings received from community.
*/
private static void overrideDefaultSettings(JsonObject clientSettings, JsonObject serverSettingJson) {
if (serverSettingJson != null && !serverSettingJson.isJsonNull()) {
if (serverSettingJson.has("response_limit")) {
int limit = serverSettingJson.get("response_limit").getAsInt();
clientSettings.addProperty("limit", limit);
}
if (serverSettingJson.has("discussion_style")) {
JsonArray discussionStyleArr = serverSettingJson.get("discussion_style").getAsJsonArray();
StringBuilder conversationStyleSB = new StringBuilder();
boolean isFirst = true;
conversationStyleSB.append("(");
for (JsonElement styleElem : discussionStyleArr) {
if (isFirst) {
isFirst = false;
} else {
conversationStyleSB.append(", ");
}
conversationStyleSB.append("'").append(styleElem.getAsString()).append("'");
}
conversationStyleSB.append(")");
if (clientSettings.has("whereClauses")) {
JsonArray whereArr = clientSettings.get("whereClauses").getAsJsonArray();
for (JsonElement whereElem : whereArr) {
JsonObject whereObj = whereElem.getAsJsonObject();
if (whereObj.has("key")) {
String key = whereObj.get("key").getAsString();
if (key.equals("conversation.style")) {
whereObj.addProperty("value", conversationStyleSB.toString());
}
}
}
}
}
}
}
示例2: checkInitialParametersForCommandExecution
import com.google.gson.JsonObject; //导入方法依赖的package包/类
/**
* This function is used to check if all the initial parameters are set for the execution of the
* {@codeEvaluateAlgorithmsCommand}.
*
* @throws CommandCannotBeExecutedException if the initial parameters are not set for the
* execution of the command
*/
private void checkInitialParametersForCommandExecution() throws CommandCannotBeExecutedException {
if (eLearningProblem == null) {
canBeExecuted = false;
throw new CommandCannotBeExecutedException(LEARNING_PROBLEM_NOTSET_ERROR_MESSAGE);
}
JsonObject evaluationConfigurationJsonObject = systemConfiguration.getJsonEvaluationConfiguration();
JsonElement evaluationName = null;
JsonElement evaluationMetrics = null;
if (evaluationConfigurationJsonObject.isJsonNull()) {
logger.warn(EVALUATION_JSONSTRING_NOTSET_WARNING_MESSAGE);
} else {
evaluationName = evaluationConfigurationJsonObject.get(EvaluationsKeyValuePairs.EVALUATION_NAME);
evaluationMetrics = evaluationConfigurationJsonObject.get(EvaluationsKeyValuePairs.EVALUATION_METRIC_ARRAY_IDENTIFIER);
}
if (evaluationIdentifier.isEmpty() && evaluationName == null) {
canBeExecuted = false;
String errorMessage = String.format(EVALUATION_IDENTIFIER_NOTSET_ERROR_MESSAGE, eLearningProblem.getLearningProblemIdentifier());
throw new CommandCannotBeExecutedException(errorMessage);
}
if (metricIdentifiers.isEmpty() && evaluationMetrics == null) {
logger.warn(EVALUATION_METRIC_IDENTIFIER_NOTSET_WARNING_MESSAGE);
}
}
示例3: buildSlackUser
import com.google.gson.JsonObject; //导入方法依赖的package包/类
static final SlackUser buildSlackUser(JsonObject jsonUser)
{
String id = GsonHelper.getStringOrNull(jsonUser.get("id"));
String name = GsonHelper.getStringOrNull(jsonUser.get("name"));
String realName = GsonHelper.getStringOrNull(jsonUser.get("real_name"));
String tz = GsonHelper.getStringOrNull(jsonUser.get("tz"));
String tzLabel = GsonHelper.getStringOrNull(jsonUser.get("tz_label"));
JsonElement element = jsonUser.get("tz_offset");
Integer tzOffset = null;
if (element != null)
{
tzOffset = element.getAsInt();
}
Boolean deleted = GsonHelper.ifNullFalse(jsonUser.get("deleted"));
Boolean admin = GsonHelper.ifNullFalse(jsonUser.get("is_admin"));
Boolean owner = GsonHelper.ifNullFalse(jsonUser.get("is_owner"));
Boolean primaryOwner = GsonHelper.ifNullFalse(jsonUser.get("is_primary_owner"));
Boolean restricted = GsonHelper.ifNullFalse(jsonUser.get("is_restricted"));
Boolean ultraRestricted = GsonHelper.ifNullFalse(jsonUser.get("is_ultra_restricted"));
Boolean bot = GsonHelper.ifNullFalse(jsonUser.get("is_bot"));
JsonObject profileJSON = GsonHelper.getJsonObjectOrNull(jsonUser.get("profile"));
String email = "";
String skype = "";
String title = "";
String phone = "";
String presence = "";
if (profileJSON !=null && !profileJSON.isJsonNull())
{
email = GsonHelper.getStringOrNull(profileJSON.get("email"));
skype = GsonHelper.getStringOrNull(profileJSON.get("skype"));
title = GsonHelper.getStringOrNull(profileJSON.get("title"));
phone = GsonHelper.getStringOrNull(profileJSON.get("phone"));
presence = GsonHelper.getStringOrNull(profileJSON.get("presence"));
}
SlackPersona.SlackPresence slackPresence = SlackPersona.SlackPresence.UNKNOWN;
if ("active".equals(presence))
{
slackPresence = SlackPersona.SlackPresence.ACTIVE;
}
if ("away".equals(presence))
{
slackPresence = SlackPersona.SlackPresence.AWAY;
}
return new SlackUserImpl(id, name, realName, email, skype, title, phone, deleted, admin, owner, primaryOwner, restricted, ultraRestricted, bot, tz, tzLabel, tzOffset == null ? null : new Integer(tzOffset.intValue()), slackPresence);
}