當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。