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


Java Module.getTypeDefinitions方法代码示例

本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.Module.getTypeDefinitions方法的典型用法代码示例。如果您正苦于以下问题:Java Module.getTypeDefinitions方法的具体用法?Java Module.getTypeDefinitions怎么用?Java Module.getTypeDefinitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opendaylight.yangtools.yang.model.api.Module的用法示例。


在下文中一共展示了Module.getTypeDefinitions方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: includedTypedefsTest

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void includedTypedefsTest() {
    final Module testModule = result.findModules("root-module").iterator().next();
    assertNotNull(testModule);

    final Set<TypeDefinition<?>> typedefs = testModule.getTypeDefinitions();
    assertEquals(2, typedefs.size());

    final Iterator<TypeDefinition<?>> typedefsIterator = typedefs.iterator();
    TypeDefinition<?> typedef = typedefsIterator.next();
    assertThat(typedef.getQName().getLocalName(), anyOf(is("new-string-type"), is("new-int32-type")));
    assertThat(typedef.getBaseType().getQName().getLocalName(), anyOf(is("string"), is("int32")));
    typedef = typedefsIterator.next();
    assertThat(typedef.getQName().getLocalName(), anyOf(is("new-string-type"), is("new-int32-type")));
    assertThat(typedef.getBaseType().getQName().getLocalName(), anyOf(is("string"), is("int32")));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:17,代码来源:IncludedStmtsTest.java

示例2: testAddedByUsesLeafTypeQName

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testAddedByUsesLeafTypeQName() throws Exception {
    final SchemaContext loadModules = TestUtils.loadModules(getClass().getResource("/added-by-uses-leaf-test")
            .toURI());
    assertEquals(2, loadModules.getModules().size());
    foo = TestUtils.findModule(loadModules, "foo").get();
    final Module imp = TestUtils.findModule(loadModules, "import-module").get();

    final LeafSchemaNode leaf = (LeafSchemaNode) ((ContainerSchemaNode) foo.getDataChildByName(QName.create(
            foo.getQNameModule(), "my-container")))
            .getDataChildByName(QName.create(foo.getQNameModule(), "my-leaf"));

    TypeDefinition<?> impType = null;
    final Set<TypeDefinition<?>> typeDefinitions = imp.getTypeDefinitions();
    for (final TypeDefinition<?> typeDefinition : typeDefinitions) {
        if (typeDefinition.getQName().getLocalName().equals("imp-type")) {
            impType = typeDefinition;
            break;
        }
    }

    assertNotNull(impType);
    assertEquals(leaf.getType().getQName(), impType.getQName());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:25,代码来源:GroupingTest.java

示例3: testIpAddress

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testIpAddress() {
    Module tested = TestUtils.findModule(context, "ietf-inet-types").get();
    Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
    TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-address");
    UnionTypeDefinition baseType = (UnionTypeDefinition) type.getBaseType();
    List<TypeDefinition<?>> unionTypes = baseType.getTypes();

    StringTypeDefinition ipv4 = (StringTypeDefinition) unionTypes.get(0);
    assertNotNull(ipv4.getBaseType());
    String expectedPattern = "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}"
            + "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])" + "(%[\\p{N}\\p{L}]+)?$";
    assertEquals(expectedPattern, ipv4.getPatternConstraints().get(0).getJavaPatternString());

    StringTypeDefinition ipv6 = (StringTypeDefinition) unionTypes.get(1);
    assertNotNull(ipv6.getBaseType());
    List<PatternConstraint> ipv6Patterns = ipv6.getPatternConstraints();
    expectedPattern = "^((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}"
            + "((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|" + "(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}"
            + "(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))" + "(%[\\p{N}\\p{L}]+)?$";
    assertEquals(expectedPattern, ipv6Patterns.get(0).getJavaPatternString());

    expectedPattern = "^(([^:]+:){6}(([^:]+:[^:]+)|(.*\\..*)))|" + "((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)"
            + "(%.+)?$";
    assertEquals(expectedPattern, ipv6Patterns.get(1).getJavaPatternString());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:27,代码来源:TypesResolutionTest.java

示例4: testDomainName

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testDomainName() {
    Module tested = TestUtils.findModule(context, "ietf-inet-types").get();
    Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
    StringTypeDefinition type = (StringTypeDefinition) TestUtils.findTypedef(typedefs, "domain-name");
    assertNotNull(type.getBaseType());
    List<PatternConstraint> patterns = type.getPatternConstraints();
    assertEquals(1, patterns.size());
    String expectedPattern = "^((([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.)*"
            + "([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.?)" + "|\\.$";
    assertEquals(expectedPattern, patterns.get(0).getJavaPatternString());

    LengthConstraint lengths = type.getLengthConstraint().get();
    assertEquals(1, lengths.getAllowedRanges().asRanges().size());
    Range<Integer> length = lengths.getAllowedRanges().span();
    assertEquals(Integer.valueOf(1), length.lowerEndpoint());
    assertEquals(Integer.valueOf(253), length.upperEndpoint());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:19,代码来源:TypesResolutionTest.java

示例5: testRequireInstanceInLeafrefs

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testRequireInstanceInLeafrefs() throws Exception {
    final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/leafref-stmt/foo.yang");
    assertNotNull(schemaContext);

    final Module foo = schemaContext.findModule("foo", Revision.of("2016-12-20")).get();
    final Set<TypeDefinition<?>> typeDefinitions = foo.getTypeDefinitions();
    assertEquals(1, typeDefinitions.size());

    final TypeDefinition<?> typeDefinition = typeDefinitions.iterator().next();
    final LeafrefTypeDefinition leafrefTypeDefinition = (LeafrefTypeDefinition) typeDefinition;
    assertTrue(leafrefTypeDefinition.requireInstance());

    final LeafSchemaNode leafrefA = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
            "leafref-a"));
    assertNotNull(leafrefA);
    assertRequireInstanceInLeafref(leafrefA, true);

    final LeafSchemaNode leafrefB = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
            "leafref-b"));
    assertNotNull(leafrefB);
    assertRequireInstanceInLeafref(leafrefB, true);

    final LeafSchemaNode leafrefC = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
            "leafref-c"));
    assertNotNull(leafrefC);
    assertRequireInstanceInLeafref(leafrefC, false);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:29,代码来源:LeafrefStatementTest.java

示例6: findTypeDef

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static boolean findTypeDef(final Module module, final QName typedef) {
    for (TypeDefinition<?> typeDefinition : module.getTypeDefinitions()) {
        if (typeDefinition.getQName().equals(typedef)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:9,代码来源:MoreRevisionsTest.java

示例7: testTypedef

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testTypedef() {
    Module testModule = TestUtils.findModule(context, "config").get();
    assertNotNull(testModule);

    Set<TypeDefinition<?>> typeDefs = testModule.getTypeDefinitions();
    assertEquals(1, typeDefs.size());

    Iterator<TypeDefinition<?>> typeDefIterator = typeDefs.iterator();
    TypeDefinition<?> typeDef = typeDefIterator.next();
    assertEquals("service-type-ref", typeDef.getQName().getLocalName());
    assertEquals(Optional.of("Internal type of references to service type identity."), typeDef.getDescription());
    assertEquals("identityref", typeDef.getBaseType().getQName().getLocalName());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:15,代码来源:YinFileTypeDefStmtTest.java

示例8: testIPVersion

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testIPVersion() {
    Module tested = TestUtils.findModule(context, "ietf-inet-types").get();
    Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
    assertEquals(14, typedefs.size());

    TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-version");
    assertTrue(type.getDescription().get().contains("This value represents the version of the IP protocol."));
    assertTrue(type.getReference().get().contains("RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"));

    EnumTypeDefinition enumType = (EnumTypeDefinition) type.getBaseType();
    List<EnumPair> values = enumType.getValues();
    assertEquals(3, values.size());

    EnumPair value0 = values.get(0);
    assertEquals("unknown", value0.getName());
    assertEquals(0, value0.getValue());
    assertEquals(Optional.of("An unknown or unspecified version of the Internet protocol."),
        value0.getDescription());

    EnumPair value1 = values.get(1);
    assertEquals("ipv4", value1.getName());
    assertEquals(1, value1.getValue());
    assertEquals(Optional.of("The IPv4 protocol as defined in RFC 791."), value1.getDescription());

    EnumPair value2 = values.get(2);
    assertEquals("ipv6", value2.getName());
    assertEquals(2, value2.getValue());
    assertEquals(Optional.of("The IPv6 protocol as defined in RFC 2460."), value2.getDescription());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:31,代码来源:TypesResolutionTest.java

示例9: testEnumeration

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testEnumeration() {
    Module tested = TestUtils.findModule(context, "custom-types-test").get();
    Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();

    TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-version");
    EnumTypeDefinition enumType = (EnumTypeDefinition) type.getBaseType();
    List<EnumPair> values = enumType.getValues();
    assertEquals(4, values.size());

    EnumPair value0 = values.get(0);
    assertEquals("unknown", value0.getName());
    assertEquals(0, value0.getValue());
    assertEquals(Optional.of("An unknown or unspecified version of the Internet protocol."),
        value0.getDescription());

    EnumPair value1 = values.get(1);
    assertEquals("ipv4", value1.getName());
    assertEquals(19, value1.getValue());
    assertEquals(Optional.of("The IPv4 protocol as defined in RFC 791."), value1.getDescription());

    EnumPair value2 = values.get(2);
    assertEquals("ipv6", value2.getName());
    assertEquals(7, value2.getValue());
    assertEquals(Optional.of("The IPv6 protocol as defined in RFC 2460."), value2.getDescription());

    EnumPair value3 = values.get(3);
    assertEquals("default", value3.getName());
    assertEquals(20, value3.getValue());
    assertEquals(Optional.of("default ip"), value3.getDescription());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:32,代码来源:TypesResolutionTest.java

示例10: testBitsType2

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testBitsType2() {
    Module tested = TestUtils.findModule(context, "custom-types-test").get();
    Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
    TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "access-operations-type");

    BitsTypeDefinition bitsType = (BitsTypeDefinition) testedType.getBaseType();
    List<Bit> bits = bitsType.getBits();
    assertEquals(5, bits.size());

    Bit bit0 = bits.get(0);
    assertEquals("create", bit0.getName());
    assertEquals(0L, bit0.getPosition());

    Bit bit1 = bits.get(1);
    assertEquals("delete", bit1.getName());
    assertEquals(365L, bit1.getPosition());

    Bit bit2 = bits.get(2);
    assertEquals("read", bit2.getName());
    assertEquals(500L, bit2.getPosition());

    Bit bit3 = bits.get(3);
    assertEquals("update", bit3.getName());
    assertEquals(501L, bit3.getPosition());

    Bit bit4 = bits.get(4);
    assertEquals("exec", bit4.getName());
    assertEquals(502L, bit4.getPosition());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:31,代码来源:TypesResolutionTest.java

示例11: testIanaTimezones

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testIanaTimezones() {
    Module tested = TestUtils.findModule(context, "iana-timezones").get();
    Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
    TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "iana-timezone");

    String expectedDesc = "A timezone location as defined by the IANA timezone";
    assertTrue(testedType.getDescription().get().contains(expectedDesc));
    assertFalse(testedType.getReference().isPresent());
    assertEquals(Status.CURRENT, testedType.getStatus());

    QName testedTypeQName = testedType.getQName();
    assertEquals(URI.create("urn:ietf:params:xml:ns:yang:iana-timezones"), testedTypeQName.getNamespace());
    assertEquals(Revision.ofNullable("2012-07-09"), testedTypeQName.getRevision());
    assertEquals("iana-timezone", testedTypeQName.getLocalName());

    EnumTypeDefinition enumType = (EnumTypeDefinition) testedType.getBaseType();
    List<EnumPair> values = enumType.getValues();
    // 0-414
    assertEquals(415, values.size());

    EnumPair enum168 = values.get(168);
    assertEquals("America/Danmarkshavn", enum168.getName());
    assertEquals(168, enum168.getValue());
    assertEquals(Optional.of("east coast, north of Scoresbysund"), enum168.getDescription());

    EnumPair enum374 = values.get(374);
    assertEquals("America/Indiana/Winamac", enum374.getName());
    assertEquals(374, enum374.getValue());
    assertEquals(Optional.of("Eastern Time - Indiana - Pulaski County"), enum374.getDescription());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:32,代码来源:TypesResolutionTest.java

示例12: testObjectId128

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testObjectId128() {
    Module tested = TestUtils.findModule(context, "ietf-yang-types").get();
    Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
    StringTypeDefinition testedType = (StringTypeDefinition) TestUtils.findTypedef(typedefs,
            "object-identifier-128");

    List<PatternConstraint> patterns = testedType.getPatternConstraints();
    assertEquals(1, patterns.size());
    PatternConstraint pattern = patterns.get(0);
    assertEquals("^\\d*(\\.\\d*){1,127}$", pattern.getJavaPatternString());

    QName testedTypeQName = testedType.getQName();
    assertEquals(URI.create("urn:ietf:params:xml:ns:yang:ietf-yang-types"), testedTypeQName.getNamespace());
    assertEquals(Revision.ofNullable("2010-09-24"), testedTypeQName.getRevision());
    assertEquals("object-identifier-128", testedTypeQName.getLocalName());

    StringTypeDefinition testedTypeBase = testedType.getBaseType();
    patterns = testedTypeBase.getPatternConstraints();
    assertEquals(1, patterns.size());

    pattern = patterns.get(0);
    assertEquals("^(([0-1](\\.[1-3]?[0-9]))|(2\\.(0|([1-9]\\d*))))(\\.(0|([1-9]\\d*)))*$",
            pattern.getJavaPatternString());

    QName testedTypeBaseQName = testedTypeBase.getQName();
    assertEquals(URI.create("urn:ietf:params:xml:ns:yang:ietf-yang-types"), testedTypeBaseQName.getNamespace());
    assertEquals(Revision.ofNullable("2010-09-24"), testedTypeBaseQName.getRevision());
    assertEquals("object-identifier", testedTypeBaseQName.getLocalName());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:31,代码来源:TypesResolutionTest.java

示例13: testIdentityref

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
@Test
public void testIdentityref() {
    Module tested = TestUtils.findModule(context, "custom-types-test").get();
    Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
    TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "service-type-ref");
    IdentityrefTypeDefinition baseType = (IdentityrefTypeDefinition) testedType.getBaseType();
    QName identity = baseType.getIdentities().iterator().next().getQName();
    assertEquals(URI.create("urn:custom.types.demo"), identity.getNamespace());
    assertEquals(Revision.ofNullable("2012-04-16"), identity.getRevision());
    assertEquals("service-type", identity.getLocalName());

    LeafSchemaNode type = (LeafSchemaNode) tested.getDataChildByName(QName.create(tested.getQNameModule(), "type"));
    assertNotNull(type);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:15,代码来源:TypesResolutionTest.java

示例14: checkThing2TypeDef

import org.opendaylight.yangtools.yang.model.api.Module; //导入方法依赖的package包/类
private static void checkThing2TypeDef(final Module badModule) {
    TypeDefinition<?> thing2 = null;
    for (TypeDefinition<?> typeDef : badModule.getTypeDefinitions()) {
        if (typeDef.getQName().getLocalName().equals("thing2")) {
            thing2 = typeDef;
            break;
        }
    }

    assertNotNull(thing2);
    TypeDefinition<?> baseType = thing2.getBaseType();
    assertEquals(QName.create("urn:opendaylight:bad", "2016-04-11", "thing"), baseType.getQName());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:14,代码来源:Bug5712Test.java


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