本文整理汇总了Java中io.bootique.meta.config.ConfigObjectMetadata类的典型用法代码示例。如果您正苦于以下问题:Java ConfigObjectMetadata类的具体用法?Java ConfigObjectMetadata怎么用?Java ConfigObjectMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigObjectMetadata类属于io.bootique.meta.config包,在下文中一共展示了ConfigObjectMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printObjectNoSubclasses
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
protected void printObjectNoSubclasses(ConfigObjectMetadata metadata) {
ConsoleAppender shifted = out.withOffset(DEFAULT_OFFSET);
ConfigSectionGenerator childGenerator = new ConfigSectionGenerator(shifted);
childGenerator.printObjectHeader(metadata);
boolean willPrintProperties = !metadata.isAbstractType() && !metadata.getProperties().isEmpty();
boolean willPrintType = metadata.getTypeLabel() != null;
if (willPrintProperties || willPrintType) {
shifted.println();
}
if (willPrintType) {
shifted.println("type: '", metadata.getTypeLabel() + "'");
}
if (willPrintProperties) {
metadata.getProperties()
.stream()
.sorted(Comparator.comparing(MetadataNode::getName))
.forEach(p -> {
p.accept(childGenerator);
});
}
}
示例2: testVisitListOfValues
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Test
public void testVisitListOfValues() {
ConfigValueMetadata listMd1 = ConfigValueMetadata.builder().type(Integer.TYPE).build();
ConfigObjectMetadata m1Config = ConfigObjectMetadata
.builder("m1root")
.description("Root config of M1")
.type(ConfigRoot1.class)
.addProperty(ConfigListMetadata.builder("p1").elementType(listMd1).build())
.build();
assertLines(m1Config,
"m1root:",
" #",
" # Root config of M1",
" # Resolved as 'io.bootique.help.config.ConfigSectionGeneratorTest$ConfigRoot1'.",
" #",
"",
" p1:",
" #",
" # Resolved as 'List'.",
" #",
" - <int>"
);
}
示例3: visitObjectMetadata
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Override
public Object visitObjectMetadata(ConfigObjectMetadata metadata) {
printNode(metadata, false);
List<ConfigObjectMetadata> selfAndSubconfigs = metadata
.getAllSubConfigs()
.map(md -> md.accept(new ConfigMetadataVisitor<ConfigObjectMetadata>() {
@Override
public ConfigObjectMetadata visitObjectMetadata(ConfigObjectMetadata visited) {
// include the root type even if it has no properties.. This ensure its header is printed in
// maps and lists
if (metadata == visited) {
return visited;
}
return visited.isAbstractType() || visited.getProperties().isEmpty() ? null : visited;
}
}))
.filter(md -> md != null)
.collect(Collectors.toList());
if (!selfAndSubconfigs.isEmpty()) {
ConfigObjectMetadata last = selfAndSubconfigs.get(selfAndSubconfigs.size() - 1);
selfAndSubconfigs.forEach(md -> {
printObjectNoSubclasses(md);
if (md != last) {
out.println();
}
});
}
return null;
}
示例4: printObjectHeader
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
protected void printObjectHeader(ConfigObjectMetadata metadata) {
out.println("#");
if (metadata.getTypeLabel() != null) {
out.println("# Type option: ", metadata.getTypeLabel());
}
printValueHeader(metadata);
out.println("#");
}
示例5: testVisitObjectConfig
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Test
public void testVisitObjectConfig() {
ConfigValueMetadata px = ConfigValueMetadata.builder("px")
.type(Bootique.class)
.description("Description line 1. Description line 2. Description line 3.").build();
ConfigObjectMetadata m1Config = ConfigObjectMetadata
.builder("m1root")
.description("Root config of M1")
.type(ConfigSectionGeneratorTest.ConfigRoot1.class)
.addProperty(px)
.build();
ConfigSectionGeneratorTest.assertLines(m1Config, 30,
"m1root:",
" #",
" # Root config of M1",
" # Resolved as 'io.bootiq",
" # ue.help.config.ConfigS",
" # ectionGeneratorTest$Co",
" # nfigRoot1'.",
" #",
"",
" # Description line 1.",
" # Description line 2.",
" # Description line 3.",
" # Resolved as 'io.bootiq",
" # ue.Bootique'.",
" px: <value>"
);
}
示例6: testVisitObjectConfig
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Test
public void testVisitObjectConfig() {
ConfigObjectMetadata m1Config = ConfigObjectMetadata
.builder("m1root")
.description("Root config of M1")
.type(ConfigRoot1.class)
.addProperty(ConfigValueMetadata.builder("p2").type(Integer.TYPE).description("Designates an integer value").build())
.addProperty(ConfigValueMetadata.builder("p1").type(String.class).build())
.addProperty(ConfigValueMetadata.builder("p0").type(Boolean.class).build())
.addProperty(ConfigValueMetadata.builder("p3").type(Bootique.class).build())
.build();
assertLines(m1Config,
"m1root:",
" #",
" # Root config of M1",
" # Resolved as 'io.bootique.help.config.ConfigSectionGeneratorTest$ConfigRoot1'.",
" #",
"",
" p0: <true|false>",
" p1: <string>",
" # Designates an integer value",
" p2: <int>",
" # Resolved as 'io.bootique.Bootique'.",
" p3: <value>"
);
}
示例7: testVisitListOfObjects
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Test
public void testVisitListOfObjects() {
ConfigObjectMetadata listMd2 = ConfigObjectMetadata.builder()
.type(ConfigRoot2.class)
.addProperty(ConfigValueMetadata.builder("p4").type(String.class).build())
.addProperty(ConfigValueMetadata.builder("p3").type(Boolean.TYPE).build())
.build();
ConfigObjectMetadata m1Config = ConfigObjectMetadata
.builder("m1root")
.description("Root config of M1")
.type(ConfigRoot1.class)
.addProperty(ConfigListMetadata.builder("p2").elementType(listMd2).description("I am a list").build())
.build();
assertLines(m1Config,
"m1root:",
" #",
" # Root config of M1",
" # Resolved as 'io.bootique.help.config.ConfigSectionGeneratorTest$ConfigRoot1'.",
" #",
"",
" p2:",
" #",
" # I am a list",
" # Resolved as 'List'.",
" #",
" -",
" #",
" # Resolved as 'io.bootique.help.config.ConfigSectionGeneratorTest$ConfigRoot2'.",
" #",
"",
" p3: <true|false>",
" p4: <string>"
);
}
示例8: testVisitMapOfValues
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Test
public void testVisitMapOfValues() throws NoSuchFieldException {
Type genericMapType = ConfigRoot2.class.getField("map").getGenericType();
ConfigValueMetadata mapValueMd = ConfigValueMetadata.builder().type(String.class).build();
ConfigMapMetadata mapMd = ConfigMapMetadata.builder("p1")
.type(genericMapType)
.keysType(Integer.class)
.valuesType(mapValueMd).build();
ConfigObjectMetadata rootMd = ConfigObjectMetadata
.builder("m1root")
.description("Root config of M1")
.type(ConfigRoot1.class)
.addProperty(mapMd)
.build();
assertLines(rootMd,
"m1root:",
" #",
" # Root config of M1",
" # Resolved as 'io.bootique.help.config.ConfigSectionGeneratorTest$ConfigRoot1'.",
" #",
"",
" p1:",
" #",
" # Resolved as 'Map<int, String>'.",
" #",
" <int>: <string>"
);
}
示例9: testVisitObjectWithMapOfObjects
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Test
public void testVisitObjectWithMapOfObjects() {
ConfigObjectMetadata mapMd = ConfigObjectMetadata.builder()
.type(ConfigRoot2.class)
.addProperty(ConfigValueMetadata.builder("p4").type(String.class).build())
.addProperty(ConfigValueMetadata.builder("p3").type(Boolean.TYPE).build())
.build();
ConfigObjectMetadata rootMd = ConfigObjectMetadata
.builder("m1root")
.description("Root config of M1")
.type(ConfigRoot1.class)
.addProperty(ConfigMapMetadata.builder("p1").keysType(String.class).valuesType(mapMd).build())
.build();
assertLines(rootMd,
"m1root:",
" #",
" # Root config of M1",
" # Resolved as 'io.bootique.help.config.ConfigSectionGeneratorTest$ConfigRoot1'.",
" #",
"",
" p1:",
" #",
" # Resolved as 'Map'.",
" #",
" <string>:",
" #",
" # Resolved as 'io.bootique.help.config.ConfigSectionGeneratorTest$ConfigRoot2'.",
" #",
"",
" p3: <true|false>",
" p4: <string>"
);
}
示例10: testFindConfig_NotFound
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Test
public void testFindConfig_NotFound() {
ConfigValueMetadata c1 = ConfigValueMetadata
.builder("r1_p1")
.description("r1_p1 desc")
.type(String.class).build();
ConfigMapMetadata c2 = ConfigMapMetadata
.builder("r2")
.description("r2 desc")
.keysType(String.class)
.valuesType(c1).build();
ConfigObjectMetadata c3 = ConfigObjectMetadata
.builder("r3")
.description("r3 desc")
.type(Object.class)
.addProperty(c2)
.build();
ModuleMetadata md = ModuleMetadata.builder("x").addConfig(c3).build();
Optional<ConfigMetadataNode> missing1 = md.findConfig("r3.rX");
assertFalse(missing1.isPresent());
Optional<ConfigMetadataNode> missing2 = md.findConfig("r2");
assertFalse(missing2.isPresent());
}
示例11: testFindConfig
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Test
public void testFindConfig() {
ConfigObjectMetadata c1 = ConfigObjectMetadata.builder("r1")
.description("r1 desc")
.type(Object.class)
.addProperty(ConfigValueMetadata.builder("r1_p1").description("r1_p1 desc").type(String.class).build())
.addProperty(ConfigValueMetadata.builder("r1_p2").description("r1_p2 desc").type(Boolean.TYPE).build())
.build();
ConfigMapMetadata c2 = ConfigMapMetadata
.builder("r2")
.description("r2 desc")
.keysType(String.class)
.valuesType(c1).build();
ConfigObjectMetadata c3 = ConfigObjectMetadata
.builder("r3")
.description("r3 desc")
.type(Object.class)
.addProperty(c2)
.build();
ModuleMetadata md = ModuleMetadata.builder("x").addConfig(c3).build();
Optional<ConfigMetadataNode> r1 = md.findConfig("r3.r2.somekey");
assertTrue(r1.isPresent());
assertEquals("r1", r1.get().getName());
assertEquals("r1 desc", r1.get().getDescription());
assertEquals(Object.class, r1.get().getType());
Optional<ConfigMetadataNode> r1P2 = md.findConfig("r3.r2.somekey.r1_p2");
assertTrue(r1P2.isPresent());
assertEquals("r1_p2", r1P2.get().getName());
assertEquals("r1_p2 desc", r1P2.get().getDescription());
assertEquals(Boolean.TYPE, r1P2.get().getType());
}
示例12: visitObjectMetadata
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Override
public Optional<ConfigObjectMetadata> visitObjectMetadata(ConfigObjectMetadata metadata) {
return Optional.of(metadata);
}
示例13: visitValueMetadata
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Override
public Optional<ConfigObjectMetadata> visitValueMetadata(ConfigValueMetadata metadata) {
return Optional.empty();
}
示例14: visitListMetadata
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Override
public Optional<ConfigObjectMetadata> visitListMetadata(ConfigListMetadata metadata) {
return Optional.empty();
}
示例15: visitMapMetadata
import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Override
public Optional<ConfigObjectMetadata> visitMapMetadata(ConfigMapMetadata metadata) {
return Optional.empty();
}