本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.getBits方法的典型用法代码示例。如果您正苦于以下问题:Java BitsTypeDefinition.getBits方法的具体用法?Java BitsTypeDefinition.getBits怎么用?Java BitsTypeDefinition.getBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition
的用法示例。
在下文中一共展示了BitsTypeDefinition.getBits方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例2: 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());
}
示例3: 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());
}
示例4: 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.");
}
}
}
示例5: 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;
}
示例6: bitsTypedefToTransferObject
import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入方法依赖的package包/类
public GeneratedTOBuilder bitsTypedefToTransferObject(final String basePackageName,
final TypeDefinition<?> typeDef, String typeDefName) {
if (typeDef == null) {
throw new IllegalArgumentException("typeDef cannot be NULL!");
}
if (basePackageName == null) {
throw new IllegalArgumentException("Base Package Name cannot be NULL!");
}
if (typeDef instanceof BitsTypeDefinition) {
BitsTypeDefinition bitsTypeDefinition = (BitsTypeDefinition) typeDef;
final String typeName = parseToClassName(typeDefName);
final GeneratedTOBuilder genTOBuilder = new GeneratedTOBuilderImpl(basePackageName, typeName);
final List<Bit> bitList = bitsTypeDefinition.getBits();
GeneratedPropertyBuilder genPropertyBuilder;
for (final Bit bit : bitList) {
String name = bit.getName();
genPropertyBuilder = genTOBuilder.addProperty(parseToValidParamName(name));
genPropertyBuilder.setReadOnly(false);
genPropertyBuilder.setReturnType(BaseYangTypes.BOOLEAN_TYPE);
genTOBuilder.addEqualsIdentity(genPropertyBuilder);
genTOBuilder.addHashIdentity(genPropertyBuilder);
genTOBuilder.addToStringProperty(genPropertyBuilder);
}
return genTOBuilder;
}
return null;
}
示例7: emitBitsSpecification
import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; //导入方法依赖的package包/类
private void emitBitsSpecification(final BitsTypeDefinition typeDefinition) {
for (final Bit bit : typeDefinition.getBits()) {
emitBit(bit);
}
}