use of org.neo4j.configuration.SettingImpl in project neo4j-documentation by neo4j.
the class ConfigDocsGenerator method document.
public String document(Predicate<SettingImpl<Object>> filter, String id, String title, String idPrefix) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
out = new PrintStream(baos);
settingDescriptions = config.getDeclaredSettings().values().stream().map(setting -> (SettingImpl<Object>) setting).filter(filter).sorted(Comparator.comparing(SettingImpl::name)).map(setting -> new DocsConfigValue(idFromName(idPrefix, setting.name()), setting.name(), description(setting), setting.deprecated(), setting.toString(), valueAsString(setting), setting.internal(), // Should be in the description if deprecated
Optional.empty(), setting.dynamic())).collect(Collectors.toList());
out.print(documentSummary(id, title, settingDescriptions));
settingDescriptions.forEach(this::documentForAllOutputs);
out.flush();
return baos.toString();
}
use of org.neo4j.configuration.SettingImpl in project neo4j-documentation by neo4j.
the class ConfigDocsTool method main.
public static void main(String[] args) throws IOException {
Args arguments = Args.parse(args);
printUsage();
List<String> orphans = arguments.orphans();
Path outFile = orphans.size() == 1 ? Paths.get(orphans.get(0)) : null;
String id = arguments.has("id") || warnMissingOption("ID", "--id=my-id", DEFAULT_ID) ? arguments.get("id") : DEFAULT_ID;
String title = arguments.has("title") || warnMissingOption("title", "--title=my-title", DEFAULT_TITLE) ? arguments.get("title") : DEFAULT_TITLE;
String idPrefix = arguments.has("id-prefix") || warnMissingOption("ID prefix", "--id-prefix=my-id-prefix", DEFAULT_ID_PREFIX) ? arguments.get("id-prefix") : DEFAULT_ID_PREFIX;
Predicate<SettingImpl<Object>> filter = filters(arguments);
System.out.printf("[+++] id=%s title=%s idPrefix=%s%n", id, title, idPrefix);
try {
String doc = new ConfigDocsGenerator().document(filter, id, title, idPrefix);
if (null != outFile) {
Path parentDir = outFile.getParent();
if (!Files.exists(parentDir)) {
Files.createDirectories(parentDir);
}
System.out.println("Saving docs in '" + outFile.toFile().getAbsolutePath() + "'.");
Files.write(outFile, doc.getBytes());
} else {
System.out.println(doc);
}
} catch (NoSuchElementException | NoSuchFileException e) {
e.printStackTrace();
throw e;
}
}
use of org.neo4j.configuration.SettingImpl in project neo4j by neo4j.
the class MemoryRecommendationsCommandTest method bytesToStringMustBeParseableBySettings.
@Test
void bytesToStringMustBeParseableBySettings() {
SettingImpl<Long> setting = (SettingImpl<Long>) SettingImpl.newBuilder("arg", BYTES, null).build();
for (int i = 1; i < 10_000; i++) {
int mebibytes = 75 * i;
long expectedBytes = mebiBytes(mebibytes);
String bytesToString = bytesToString(expectedBytes);
long actualBytes = setting.parse(bytesToString);
long tenPercent = (long) (expectedBytes * 0.1);
assertThat(actualBytes).as(mebibytes + "m").isBetween(expectedBytes - tenPercent, expectedBytes + tenPercent);
}
}
Aggregations