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


Java BitsTypeDefinition类代码示例

本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition的典型用法代码示例。如果您正苦于以下问题:Java BitsTypeDefinition类的具体用法?Java BitsTypeDefinition怎么用?Java BitsTypeDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BitsTypeDefinition类属于org.opendaylight.yangtools.yang.model.api.type包,在下文中一共展示了BitsTypeDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBitsType1

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
@Test
public void testBitsType1() {
    Module tested = TestUtils.findModule(context, "custom-types-test").get();
    LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName(
            QName.create(tested.getQNameModule(), "mybits"));
    BitsTypeDefinition leafType = (BitsTypeDefinition) leaf.getType();
    List<Bit> bits = leafType.getBits();
    assertEquals(3, bits.size());

    Bit bit1 = bits.get(0);
    assertEquals("disable-nagle", bit1.getName());
    assertEquals(0L, bit1.getPosition());

    Bit bit2 = bits.get(1);
    assertEquals("auto-sense-speed", bit2.getName());
    assertEquals(1L, bit2.getPosition());

    Bit bit3 = bits.get(2);
    assertEquals("10-Mb-only", bit3.getName());
    assertEquals(2L, bit3.getPosition());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:22,代码来源:TypesResolutionTest.java

示例2: bitsTypeTest

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
@Test
public void bitsTypeTest() {
    final BitsTypeBuilder bitsTypeBuilder = BaseTypes.bitsTypeBuilder(SCHEMA_PATH);
    bitsTypeBuilder.addBit(BIT_A);
    final BitsTypeDefinition bitsTypeDefinition1 = bitsTypeBuilder.build();
    final BitsTypeDefinition bitsTypeDefinition2 = bitsTypeBuilder.build();
    hashCodeEqualsToStringTest(bitsTypeDefinition1, bitsTypeDefinition2);
    assertEquals(bitsTypeDefinition1.getBits(), bitsTypeDefinition1.getBits());

    final DerivedBitsType derivedBitsType1 = (DerivedBitsType)DerivedTypes
            .derivedTypeBuilder(bitsTypeDefinition1, SCHEMA_PATH).build();
    final DerivedBitsType derivedBitsType2 = (DerivedBitsType)DerivedTypes
            .derivedTypeBuilder(bitsTypeDefinition2, SCHEMA_PATH).build();
    hashCodeEqualsToStringTest(derivedBitsType1, derivedBitsType2);

    restrictedBuilderTest(RestrictedTypes.newBitsBuilder(bitsTypeDefinition1, SCHEMA_PATH),
            RestrictedTypes.newBitsBuilder(bitsTypeDefinition2, SCHEMA_PATH));
    concreteBuilderTest(bitsTypeDefinition1, derivedBitsType1);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:20,代码来源:TypeTest.java

示例3: addEnclosedTOToTypeBuilder

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
private GeneratedTOBuilder addEnclosedTOToTypeBuilder(TypeDefinition<?> typeDef, GeneratedTypeBuilder typeBuilder,
        String leafName) {
    String className = parseToClassName(leafName);
    GeneratedTOBuilder genTOBuilder = null;
    if (typeDef instanceof UnionType) {
        genTOBuilder = ((TypeProviderImpl) typeProvider).addUnionGeneratedTypeDefinition(
                typeBuilder.getFullyQualifiedName(), typeDef, className);
    } else if (typeDef instanceof BitsTypeDefinition) {
        genTOBuilder = ((TypeProviderImpl) typeProvider).bitsTypedefToTransferObject(
                typeBuilder.getFullyQualifiedName(), typeDef, className);
    }
    if (genTOBuilder != null) {
        typeBuilder.addEnclosingTransferObject(genTOBuilder);
        return genTOBuilder;
    }
    return null;

}
 
开发者ID:lbchen,项目名称:ODL,代码行数:19,代码来源:BindingGeneratorImpl.java

示例4: emitTypeBodyNodes

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
private void emitTypeBodyNodes(final TypeDefinition<?> typeDef) {
    if (typeDef instanceof DecimalTypeDefinition) {
        emitDecimal64Specification((DecimalTypeDefinition) typeDef);
    } else if (typeDef instanceof RangeRestrictedTypeDefinition) {
        emitRangeRestrictedSpecification((RangeRestrictedTypeDefinition<?, ?>) typeDef);
    } else if (typeDef instanceof StringTypeDefinition) {
        emitStringRestrictions((StringTypeDefinition) typeDef);
    } else if (typeDef instanceof EnumTypeDefinition) {
        emitEnumSpecification((EnumTypeDefinition) typeDef);
    } else if (typeDef instanceof LeafrefTypeDefinition) {
        emitLeafrefSpecification((LeafrefTypeDefinition) typeDef);
    } else if (typeDef instanceof IdentityrefTypeDefinition) {
        emitIdentityrefSpecification((IdentityrefTypeDefinition) typeDef);
    } else if (typeDef instanceof InstanceIdentifierTypeDefinition) {
        emitInstanceIdentifierSpecification((InstanceIdentifierTypeDefinition) typeDef);
    } else if (typeDef instanceof BitsTypeDefinition) {
        emitBitsSpecification((BitsTypeDefinition) typeDef);
    } else if (typeDef instanceof UnionTypeDefinition) {
        emitUnionSpecification((UnionTypeDefinition) typeDef);
    } else if (typeDef instanceof BinaryTypeDefinition) {
        ((BinaryTypeDefinition) typeDef).getLengthConstraint().ifPresent(this::emitLength);
    } else if (typeDef instanceof BooleanTypeDefinition || typeDef instanceof EmptyTypeDefinition) {
        // NOOP
    } else {
        throw new IllegalArgumentException("Not supported type " + typeDef.getClass());
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:28,代码来源:SchemaContextEmitter.java

示例5: BitsStringCodec

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private BitsStringCodec(final Optional<BitsTypeDefinition> typeDef) {
    super(typeDef, (Class<Set<String>>) (Class<?>) Set.class);
    if (typeDef.isPresent()) {
        validBits = ImmutableSet.copyOf(Collections2.transform(typeDef.get().getBits(), Bit::getName));
    } else {
        validBits = null;
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:10,代码来源:BitsStringCodec.java

示例6: fromType

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
public static TypeDefinitionAwareCodec<?, ?> fromType(final TypeDefinition<?> typeDefinition) {
    final TypeDefinitionAwareCodec<?, ?> codec;

    if (typeDefinition instanceof BinaryTypeDefinition) {
        codec = BinaryStringCodec.from((BinaryTypeDefinition)typeDefinition);
    } else if (typeDefinition instanceof BitsTypeDefinition) {
        codec = BitsStringCodec.from((BitsTypeDefinition)typeDefinition);
    } else if (typeDefinition instanceof BooleanTypeDefinition) {
        codec = BooleanStringCodec.from((BooleanTypeDefinition)typeDefinition);
    } else if (typeDefinition instanceof DecimalTypeDefinition) {
        codec = DecimalStringCodec.from((DecimalTypeDefinition)typeDefinition);
    } else if (typeDefinition instanceof EmptyTypeDefinition) {
        codec = EmptyStringCodec.INSTANCE;
    } else if (typeDefinition instanceof EnumTypeDefinition) {
        codec = EnumStringCodec.from((EnumTypeDefinition)typeDefinition);
    } else if (typeDefinition instanceof Int8TypeDefinition) {
        codec = AbstractIntegerStringCodec.from((Int8TypeDefinition) typeDefinition);
    } else if (typeDefinition instanceof Int16TypeDefinition) {
        codec = AbstractIntegerStringCodec.from((Int16TypeDefinition) typeDefinition);
    } else if (typeDefinition instanceof Int32TypeDefinition) {
        codec = AbstractIntegerStringCodec.from((Int32TypeDefinition) typeDefinition);
    } else if (typeDefinition instanceof Int64TypeDefinition) {
        codec = AbstractIntegerStringCodec.from((Int64TypeDefinition) typeDefinition);
    } else if (typeDefinition instanceof StringTypeDefinition) {
        codec = StringStringCodec.from((StringTypeDefinition)typeDefinition);
    } else if (typeDefinition instanceof UnionTypeDefinition) {
        codec = UnionStringCodec.from((UnionTypeDefinition)typeDefinition);
    } else if (typeDefinition instanceof Uint8TypeDefinition) {
        codec = AbstractIntegerStringCodec.from((Uint8TypeDefinition) typeDefinition);
    } else if (typeDefinition instanceof Uint16TypeDefinition) {
        codec = AbstractIntegerStringCodec.from((Uint16TypeDefinition) typeDefinition);
    } else if (typeDefinition instanceof Uint32TypeDefinition) {
        codec = AbstractIntegerStringCodec.from((Uint32TypeDefinition) typeDefinition);
    } else if (typeDefinition instanceof Uint64TypeDefinition) {
        codec = AbstractIntegerStringCodec.from((Uint64TypeDefinition) typeDefinition);
    } else {
        codec = null;
    }
    return codec;
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:41,代码来源:TypeDefinitionAwareCodec.java

示例7: toBitsTypeDefinition

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
private  static BitsTypeDefinition toBitsTypeDefinition(final String... bits) {
    final BitsTypeBuilder b = BaseTypes.bitsTypeBuilder(mock(SchemaPath.class));

    long pos = 0;
    for (String bit : bits) {
        BitsTypeDefinition.Bit mockBit = mock(BitsTypeDefinition.Bit.class);
        when(mockBit.getName()).thenReturn(bit);
        when(mockBit.getPosition()).thenReturn(pos);
        b.addBit(mockBit);
        ++pos;
    }

    return b.build();
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:15,代码来源:BitsCodecStringTest.java

示例8: equals

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final BitsTypeDefinition.Bit other = (BitsTypeDefinition.Bit) obj;
    return Objects.equals(qname, other.getQName()) && Objects.equals(schemaPath, other.getPath());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:15,代码来源:BitEffectiveStatementImpl.java

示例9: BitsTypeEffectiveStatementImpl

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
BitsTypeEffectiveStatementImpl(
        final StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx,
        final BitsTypeDefinition baseType) {
    super(ctx);

    final BitsTypeBuilder builder = RestrictedTypes.newBitsBuilder(baseType, ctx.getSchemaPath().get());

    final YangVersion yangVersion = ctx.getRootVersion();
    for (final EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
        if (stmt instanceof BitEffectiveStatementImpl) {
            SourceException.throwIf(yangVersion != YangVersion.VERSION_1_1, ctx.getStatementSourceReference(),
                    "Restricted bits type is allowed only in YANG 1.1 version.");
            final BitEffectiveStatementImpl bitSubStmt = (BitEffectiveStatementImpl) stmt;

            final long effectivePos;
            if (bitSubStmt.getDeclaredPosition() == null) {
                effectivePos = getBaseTypeBitPosition(bitSubStmt.getName(), baseType, ctx);
            } else {
                effectivePos = bitSubStmt.getDeclaredPosition();
            }

            builder.addBit(EffectiveTypeUtil.buildBit(bitSubStmt, effectivePos));
        } else if (stmt instanceof UnknownSchemaNode) {
            builder.addUnknownSchemaNode((UnknownSchemaNode) stmt);
        }
    }

    typeDefinition = builder.build();
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:30,代码来源:BitsTypeEffectiveStatementImpl.java

示例10: getBaseTypeBitPosition

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
private static long getBaseTypeBitPosition(final String bitName, final BitsTypeDefinition baseType,
        final StmtContext<?, ?, ?> ctx) {
    for (Bit baseTypeBit : baseType.getBits()) {
        if (bitName.equals(baseTypeBit.getName())) {
            return baseTypeBit.getPosition();
        }
    }

    throw new SourceException(ctx.getStatementSourceReference(),
            "Bit '%s' is not a subset of its base bits type %s.", bitName, baseType.getQName());
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:12,代码来源:BitsTypeEffectiveStatementImpl.java

示例11: testBitsType2

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的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

示例12: verifyBitsTypedefinition

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
private static void verifyBitsTypedefinition(final SchemaContext context) {
    final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "bits-leaf"));
    assertTrue(dataChildByName instanceof LeafSchemaNode);
    final LeafSchemaNode bitsLeaf = (LeafSchemaNode) dataChildByName;
    final TypeDefinition<? extends TypeDefinition<?>> type = bitsLeaf.getType();
    assertTrue(type instanceof BitsTypeDefinition);
    final BitsTypeDefinition myBits = (BitsTypeDefinition) type;
    final List<Bit> positions = myBits.getBits();
    for (final Bit bit : positions) {
        final String name = bit.getName();
        switch (name) {
            case "zero":
                assertEquals(0, bit.getPosition());
                break;
            case "twenty":
                assertEquals(20, bit.getPosition());
                break;
            case "twenty-one":
                assertEquals(21, bit.getPosition());
                break;
            case "two":
                assertEquals(2, bit.getPosition());
                break;
            case "twenty-two":
                assertEquals(22, bit.getPosition());
                break;
            default:
                fail("Unexpected bit name.");
        }
    }
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:32,代码来源:Bug6316Test.java

示例13: containsBit

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
private static boolean containsBit(final BitsTypeDefinition bitsType, final String bitName) {
    for (BitsTypeDefinition.Bit bit : bitsType.getBits()) {
        if (bitName.equals(bit.getName())) {
            return true;
        }
    }

    return false;
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:10,代码来源:YangFunctionContext.java

示例14: derivedBitsBuilder

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
public static DerivedTypeBuilder<BitsTypeDefinition> derivedBitsBuilder(final BitsTypeDefinition baseType,
        final SchemaPath path) {
    return new DerivedTypeBuilder<BitsTypeDefinition>(baseType, path) {
        @Override
        public BitsTypeDefinition build() {
            return new DerivedBitsType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
                    getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
        }
    };
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:11,代码来源:DerivedTypes.java

示例15: concreteBitsBuilder

import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入依赖的package包/类
private static ConcreteTypeBuilder<BitsTypeDefinition> concreteBitsBuilder(final BitsTypeDefinition baseType,
        final SchemaPath path) {
    return new ConcreteTypeBuilder<BitsTypeDefinition>(baseType, path) {
        @Nonnull
        @Override
        public BitsTypeDefinition buildType() {
            return new DerivedBitsType(getBaseType(), getPath(), getDefaultValue(), getDescription(),
                    getReference(), getStatus(), getUnits(), getUnknownSchemaNodes());
        }
    };
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:12,代码来源:ConcreteTypes.java


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