|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -62,10 +62,10 @@ class JsonConverter {
|
|
|
|
public JSONObject toJsonObject(ItemMetadata item) throws Exception {
|
|
|
|
public JSONObject toJsonObject(ItemMetadata item) throws Exception {
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
jsonObject.put("name", item.getName());
|
|
|
|
jsonObject.put("name", item.getName());
|
|
|
|
putIfPresent(jsonObject, "type", item.getType());
|
|
|
|
jsonObject.putOpt("type", item.getType());
|
|
|
|
putIfPresent(jsonObject, "description", item.getDescription());
|
|
|
|
jsonObject.putOpt("description", item.getDescription());
|
|
|
|
putIfPresent(jsonObject, "sourceType", item.getSourceType());
|
|
|
|
jsonObject.putOpt("sourceType", item.getSourceType());
|
|
|
|
putIfPresent(jsonObject, "sourceMethod", item.getSourceMethod());
|
|
|
|
jsonObject.putOpt("sourceMethod", item.getSourceMethod());
|
|
|
|
Object defaultValue = item.getDefaultValue();
|
|
|
|
Object defaultValue = item.getDefaultValue();
|
|
|
|
if (defaultValue != null) {
|
|
|
|
if (defaultValue != null) {
|
|
|
|
putDefaultValue(jsonObject, defaultValue);
|
|
|
|
putDefaultValue(jsonObject, defaultValue);
|
|
|
@ -111,7 +111,7 @@ class JsonConverter {
|
|
|
|
private JSONObject getItemHintValue(ItemHint.ValueHint value) throws Exception {
|
|
|
|
private JSONObject getItemHintValue(ItemHint.ValueHint value) throws Exception {
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
putHintValue(result, value.getValue());
|
|
|
|
putHintValue(result, value.getValue());
|
|
|
|
putIfPresent(result, "description", value.getDescription());
|
|
|
|
result.putOpt("description", value.getDescription());
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -137,13 +137,6 @@ class JsonConverter {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void putIfPresent(JSONObject jsonObject, String name, Object value)
|
|
|
|
|
|
|
|
throws Exception {
|
|
|
|
|
|
|
|
if (value != null) {
|
|
|
|
|
|
|
|
jsonObject.put(name, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void putHintValue(JSONObject jsonObject, Object value) throws Exception {
|
|
|
|
private void putHintValue(JSONObject jsonObject, Object value) throws Exception {
|
|
|
|
Object hintValue = extractItemValue(value);
|
|
|
|
Object hintValue = extractItemValue(value);
|
|
|
|
jsonObject.put("value", hintValue);
|
|
|
|
jsonObject.put("value", hintValue);
|
|
|
|