Due to a ransomware attack, the wiki was reverted to a July 2022 version. . We apologize for the lack of a more recent valid backup.
...
Code Block | ||
---|---|---|
| ||
File : TunnelType.java public abstract class TunnelType { } File : NetworkId.java public interface NetworkId { TunnelType leafNetworkId(); interface NetworkIdBuilder { TunnelType leafNetworkId(); NetworkIdBuilder leafNetworkId(TunnelType leafNetworkId); NetworkId build(); } } |
Bits
Overview
The bits built-in type represents a bit set. That is, a bits value is a set of flags identified by small integer position numbers starting at 0. Each bit number has an assigned name.
Java mapping
Container BitSet is used to store bits during code generation.
Example
Code Block | ||
---|---|---|
| ||
File : test.yang
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
typedef MyBits {
type bits {
bit disable-nagle {
position 0;
}
bit auto-sense-speed {
position 1;
}
bit Mb-only {
position 2;
}
}
}
} |
Code Block | ||
---|---|---|
| ||
File: MyBits.java
package org.onosproject.yang.gen.v1.http.huawei.com.rev20160718.test;
import java.util.BitSet;
import java.util.Objects;
import com.google.common.base.MoreObjects;
/**
* Represents the implementation of myBits.
*/
public final class MyBits {
private BitSet bits;
/**
* Creates an instance of myBits.
*/
private MyBits() {
}
/**
* Creates an instance of myBitsForTypeBits.
*
* @param value value of myBitsForTypeBits
*/
public MyBits(BitSet value) {
this.bits = value;
}
/**
* Returns the object of myBitsForTypeBits.
*
* @param value value of myBitsForTypeBits
* @return Object of myBitsForTypeBits
*/
public static MyBits of(BitSet value) {
return new MyBits(value);
}
/**
* Returns the attribute bits.
*
* @return value of bits
*/
public BitSet bits() {
return bits;
}
@Override
public int hashCode() {
return Objects.hash(bits);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof MyBits) {
MyBits other = (MyBits) obj;
return
Objects.equals(bits, other.bits);
}
return false;
}
@Override
public String toString() {
return bits.toString();
}
/**
* Returns the object of myBits fromString input String.
*
* @param valInString input String
* @return Object of myBits
*/
public static MyBits fromString(String valInString) {
try {
BitSet tmpVal = new BitSet();
valInString = valInString.replace('{', ' ');
valInString = valInString.replace('}', ' ');
valInString = valInString.trim();
String[] bitsTemp = valInString.split(",", 0);
for (String bitTemp : bitsTemp) {
bitTemp = bitTemp.trim();
tmpVal.set(Integer.parseInt(bitTemp));
};
return of(tmpVal);
} catch (Exception e) {
}
return null;
}
} |
Golden Eye Demo
Link: https://www.youtube.com/watch?v=ipbu0x0LcDk
...