use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class MergeMetadataGenerationTests method writeAdditionalHints.
private void writeAdditionalHints(ItemHint... hints) throws Exception {
TestJsonConverter converter = new TestJsonConverter();
File additionalMetadataFile = createAdditionalMetadataFile();
JSONObject additionalMetadata = new JSONObject();
additionalMetadata.put("hints", converter.toJsonArray(Arrays.asList(hints)));
writeMetadata(additionalMetadataFile, additionalMetadata);
}
use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class MergeMetadataGenerationTests method mergingOfAdditionalMetadata.
@Test
void mergingOfAdditionalMetadata() throws Exception {
File metaInfDirectory = new File(getCompiler().getOutputLocation(), "META-INF");
metaInfDirectory.mkdirs();
File additionalMetadataFile = new File(metaInfDirectory, "additional-spring-configuration-metadata.json");
additionalMetadataFile.createNewFile();
JSONObject property = new JSONObject();
property.put("name", "foo");
property.put("type", "java.lang.String");
property.put("sourceType", AdditionalMetadata.class.getName());
JSONArray properties = new JSONArray();
properties.put(property);
JSONObject additionalMetadata = new JSONObject();
additionalMetadata.put("properties", properties);
FileWriter writer = new FileWriter(additionalMetadataFile);
writer.append(additionalMetadata.toString(2));
writer.flush();
writer.close();
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata).has(Metadata.withProperty("simple.comparator"));
assertThat(metadata).has(Metadata.withProperty("foo", String.class).fromSource(AdditionalMetadata.class));
}
use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonConverter method getItemHintValue.
private JSONObject getItemHintValue(ItemHint.ValueHint value) throws Exception {
JSONObject result = new JSONObject();
putHintValue(result, value.getValue());
result.putOpt("description", value.getDescription());
return result;
}
use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonConverter method toJsonObject.
private JSONObject toJsonObject(ItemHint hint) throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", hint.getName());
if (!hint.getValues().isEmpty()) {
jsonObject.put("values", getItemHintValues(hint));
}
if (!hint.getProviders().isEmpty()) {
jsonObject.put("providers", getItemHintProviders(hint));
}
return jsonObject;
}
use of org.springframework.boot.configurationprocessor.json.JSONObject in project spring-boot by spring-projects.
the class JsonConverter method putDefaultValue.
private void putDefaultValue(JSONObject jsonObject, Object value) throws Exception {
Object defaultValue = extractItemValue(value);
jsonObject.put("defaultValue", defaultValue);
}
Aggregations