Java Code Examples for io.spring.initializr.metadata.InitializrMetadata#defaults()

The following examples show how to use io.spring.initializr.metadata.InitializrMetadata#defaults() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandLineHelpGenerator.java    From initializr with Apache License 2.0 6 votes vote down vote up
protected Map<String, Object> initializeSpringBootCliModel(InitializrMetadata metadata, String serviceUrl) {
	Map<String, Object> model = new LinkedHashMap<>();
	model.put("logo", LOGO);
	model.put("serviceUrl", serviceUrl);
	model.put("dependencies", generateDependencyTable(metadata));
	model.put("types", generateTypeTable(metadata, "Id", true));

	Map<String, Object> defaults = metadata.defaults();
	Map<String, Object> parametersDescription = buildParametersDescription(metadata);
	String[][] parameterTable = new String[defaults.size() + 1][];
	parameterTable[0] = new String[] { "Id", "Description", "Default value" };
	int i = 1;
	for (String id : defaults.keySet().stream().sorted().collect(Collectors.toList())) {
		String[] data = new String[3];
		data[0] = id;
		data[1] = (String) parametersDescription.get(id);
		data[2] = (String) defaults.get(id);
		parameterTable[i++] = data;
	}
	model.put("parameters", TableGenerator.generate(parameterTable, this.maxColumnWidth));
	return model;
}
 
Example 2
Source File: CommandLineHelpGenerator.java    From initializr with Apache License 2.0 5 votes vote down vote up
protected Map<String, Object> initializeCommandLineModel(InitializrMetadata metadata, String serviceUrl) {
	Map<String, Object> model = new LinkedHashMap<>();
	model.put("logo", LOGO);
	model.put("serviceUrl", serviceUrl);
	model.put("dependencies", generateDependencyTable(metadata));
	model.put("types", generateTypeTable(metadata, "Rel", false));

	Map<String, Object> defaults = metadata.defaults();
	defaults.put("applicationName",
			metadata.getConfiguration().generateApplicationName(metadata.getName().getContent()));
	defaults.put("baseDir", "no base dir");
	defaults.put("dependencies", "none");

	Map<String, Object> parametersDescription = buildParametersDescription(metadata);
	String[][] parameterTable = new String[defaults.size() + 1][];
	parameterTable[0] = new String[] { "Parameter", "Description", "Default value" };
	int i = 1;
	for (String id : defaults.keySet().stream().sorted().collect(Collectors.toList())) {
		String[] data = new String[3];
		data[0] = id;
		data[1] = (String) parametersDescription.get(id);
		data[2] = (String) defaults.get(id);
		parameterTable[i++] = data;
	}
	model.put("parameters", TableGenerator.generate(parameterTable, this.maxColumnWidth));

	return model;
}