当前位置: 首页>>代码示例>>Java>>正文


Java ConfigObjectMetadata类代码示例

本文整理汇总了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);
                    });
        }
    }
 
开发者ID:bootique,项目名称:bootique,代码行数:27,代码来源:ConfigSectionGenerator.java

示例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>"
    );
}
 
开发者ID:bootique,项目名称:bootique,代码行数:27,代码来源:ConfigSectionGeneratorTest.java

示例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;
}
 
开发者ID:bootique,项目名称:bootique,代码行数:36,代码来源:ConfigSectionGenerator.java

示例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("#");
    }
 
开发者ID:bootique,项目名称:bootique,代码行数:12,代码来源:ConfigSectionGenerator.java

示例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>"
    );
}
 
开发者ID:bootique,项目名称:bootique,代码行数:33,代码来源:ConfigSectionGeneratorFoldingTest.java

示例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>"
    );
}
 
开发者ID:bootique,项目名称:bootique,代码行数:29,代码来源:ConfigSectionGeneratorTest.java

示例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>"
    );
}
 
开发者ID:bootique,项目名称:bootique,代码行数:38,代码来源:ConfigSectionGeneratorTest.java

示例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>"
    );
}
 
开发者ID:bootique,项目名称:bootique,代码行数:33,代码来源:ConfigSectionGeneratorTest.java

示例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>"
    );
}
 
开发者ID:bootique,项目名称:bootique,代码行数:37,代码来源:ConfigSectionGeneratorTest.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique,代码行数:30,代码来源:ModuleMetadataTest.java

示例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());
}
 
开发者ID:bootique,项目名称:bootique,代码行数:38,代码来源:ModuleMetadataTest.java

示例12: visitObjectMetadata

import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Override
public Optional<ConfigObjectMetadata> visitObjectMetadata(ConfigObjectMetadata metadata) {
    return Optional.of(metadata);
}
 
开发者ID:bootique,项目名称:bootique,代码行数:5,代码来源:ModuleMetadata.java

示例13: visitValueMetadata

import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Override
public Optional<ConfigObjectMetadata> visitValueMetadata(ConfigValueMetadata metadata) {
    return Optional.empty();
}
 
开发者ID:bootique,项目名称:bootique,代码行数:5,代码来源:ModuleMetadata.java

示例14: visitListMetadata

import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Override
public Optional<ConfigObjectMetadata> visitListMetadata(ConfigListMetadata metadata) {
    return Optional.empty();
}
 
开发者ID:bootique,项目名称:bootique,代码行数:5,代码来源:ModuleMetadata.java

示例15: visitMapMetadata

import io.bootique.meta.config.ConfigObjectMetadata; //导入依赖的package包/类
@Override
public Optional<ConfigObjectMetadata> visitMapMetadata(ConfigMapMetadata metadata) {
    return Optional.empty();
}
 
开发者ID:bootique,项目名称:bootique,代码行数:5,代码来源:ModuleMetadata.java


注:本文中的io.bootique.meta.config.ConfigObjectMetadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。