if (isNullOrEmpty(property.getValues())) {
result = null;
} else if (propDef.getCardinality() == Cardinality.SINGLE) {
result = getJSONValue(property.getValues().get(0), dateTimeFormat);
} else {
JSONArray values = new JSONArray();
for (Object value : property.getValues()) {
values.add(getJSONValue(value, dateTimeFormat));
}
result = values;
}
} else {
if (isNullOrEmpty(property.getValues())) {
result = null;
} else {
JSONArray values = new JSONArray();
for (Object value : property.getValues()) {
values.add(getJSONValue(value, dateTimeFormat));
}
result = values;
}
}
return result;
} else {
JSONObject result = new JSONObject();
result.put(JSON_PROPERTY_ID, property.getId());
setIfNotNull(JSON_PROPERTY_LOCALNAME, property.getLocalName(), result);
setIfNotNull(JSON_PROPERTY_DISPLAYNAME, property.getDisplayName(), result);
setIfNotNull(JSON_PROPERTY_QUERYNAME, property.getQueryName(), result);
if (propDef != null) {
result.put(JSON_PROPERTY_DATATYPE, getJSONEnumValue(propDef.getPropertyType()));
result.put(JSON_PROPERTY_CARDINALITY, getJSONEnumValue(propDef.getCardinality()));
if (isNullOrEmpty(property.getValues())) {
result.put(JSON_PROPERTY_VALUE, null);
} else if (propDef.getCardinality() == Cardinality.SINGLE) {
result.put(JSON_PROPERTY_VALUE, getJSONValue(property.getValues().get(0), dateTimeFormat));
} else {
JSONArray values = new JSONArray();
for (Object value : property.getValues()) {
values.add(getJSONValue(value, dateTimeFormat));
}
result.put(JSON_PROPERTY_VALUE, values);
}
} else {
result.put(JSON_PROPERTY_DATATYPE, getJSONPropertyDataType(property));
if (isNullOrEmpty(property.getValues())) {
result.put(JSON_PROPERTY_VALUE, null);
} else {
JSONArray values = new JSONArray();
for (Object value : property.getValues()) {
values.add(getJSONValue(value, dateTimeFormat));
}
result.put(JSON_PROPERTY_VALUE, values);
}
}