Table of ContentsmaxLevel 4
Team
maxLevel | 4 |
---|
Name | Organization | |
---|---|---|
Adarsh M | Huawei Technologies | adarsh.m@huawei.com |
Bharat Saraswal | Huawei Technologies | bharat.saraswal@huawei.com |
Gaurav Agrawal | Huawei Technologies | gaurav.agrawal@huawei.com |
Janani B | Huawei Technologies | janani.b@huawei.com |
Sathish Kumar M | Huawei Technologies | sathishkumar.m@huawei.com |
Suchitra H N | Huawei Technologies | suchitra.hn@huawei.com |
Vidyashree Rama | Huawei Technologies | vidyashree.rama@huawei.com |
Vinod Kumar S | Huawei Technologies | vinods.kumar@huawei.com |
Shankara | Huawei Technologies | |
Mahesh Poojary S | Huawei Technologies | |
Rama Subba Reddy S | Huawei Technologies | |
Sonu Gupta | Huawei Technologies | sonu.gupta@huawei.com |
A U surya | Huawei Technologies |
Overview
YANG is a data modeling language used to model configuration & state data. Modeling languages such as SMI (SNMP), UML, XML Schema, and others already existed. However, none of these languages were specifically targeted to the needs of configuration management. They lacked critical capabilities like being easily read and understood by human implementers, and fell short in providing mechanisms to validate models of configuration data for semantics and syntax.
...
Step 3 : Build using buck build onos command. Generated java code will be placed in default directory or in desired destination folder configured by user.
Yang Maven Plugin :
Step1 : Create a test app and add YANG tools maven plugin to pom file’s build section
...
YANG tools constructs support/plan
YANG Construct | Supported/Planned version |
---|---|
anyxml | Not planned |
argument | Hummingbird(partial support) |
augment | Goldeneye |
uses-augment |
Loon | |
base | Hummingbird |
belongs-to | Goldeneye |
bit | Hummingbird |
case | Goldeneye |
choice | Goldeneye |
config | Falcon |
contact | Goldeneye Enhancement in Hummingbird |
container | Falcon |
default | Goldeneye Enhancement in Humminbird |
description | Goldeneye Enhancement in Hummingbird |
deviate | Not planned |
deviation | Not planned |
enum | Goldeneye |
error-app-tag | Hummingbird |
error-message | Hummingbird |
extension | Hummingbird(partial support) |
feature | Hummingbird |
fraction-digits | Hummingbird |
grouping | Goldeneye |
identity | Hummingbird |
if-feature | Hummingbird |
import | Goldeneye Enhancement in Hummingbird |
include | Goldeneye Enhancement in Hummingbird |
input | Goldeneye |
key | Goldeneye |
leaf | Falcon |
leaf-list | Falcon |
length | Goldeneye |
list | Falcon |
mandatory | Falcon |
max-elements | Goldeneye |
min-elements | Goldeneye |
module | Falcon |
must | Hummingbird |
namespace | Goldeneye |
notification | Goldeneye |
ordered-by | Not planned |
organization | Goldeneye Enhancement in Hummingbird |
output | Goldeneye |
path | Hummingbird |
pattern | Goldeneye |
position | Goldeneye |
prefix | Goldeneye |
presence | Goldeneye |
range | Goldeneye |
reference | Goldeneye Enhancement in Hummingbird |
refine | Not planned |
require-instance | Hummingbird |
revision | Goldeneye Enhancement in Hummingbird |
revision-date | Goldeneye |
rpc | Goldeneye |
status | Goldeneye Enhancement in Hummingbird |
submodule | Goldeneye |
type | Goldeneye |
typedef | Goldeneye |
unique | Kingfisher |
unknown | Kingfisher |
units | Goldeneye |
uses | Goldeneye Enhancement in Hummingbird |
value | Goldeneye |
when | Hummingbird |
yang-version | Goldeneye |
yin-element | Not Planned |
Built-in YANG data types support/plan
Binary | Goldeneye Enhancement in Hummingbird |
Bits | Goldeneye Enhancement in Hummingbird |
boolean | Goldeneye |
decimal64 | Goldeneye Enhancement in Hummingbird |
empty | Goldeneye |
enumeration | Goldeneye |
identityref | Hummingbird |
instance-identifier | Hummingbird |
int8 | Goldeneye |
int16 | Goldeneye |
int32 | Goldeneye |
int64 | Goldeneye |
leafref | Hummingbird |
string | Falcon |
uint8 | Goldeneye |
uint16 | Goldeneye |
uint32 | Goldeneye |
uint64 | Goldeneye |
union | Goldeneye |
Generated JAVA Details
Common behavior
...
Code Block | ||
---|---|---|
| ||
File : NetworkService.java package org.onosproject.yang.gen.v1.urn.tbd.params.xml.ns.yang.nodes.rev20140309; import org.onosproject.yang.gen.v1.urn.tbd.params.xml.ns.yang.nodes.rev20140309.network.rpctest.RpcTestInput; /** * Abstraction of an entity which represents the functionality of network. */ public interface NetworkService { /** * Service interface of rpcTest. * * @param inputVar input of service interface rpcTest */ void rpcTest(RpcTestInput inputVar); } File : Network.java package org.onosproject.yang.gen.v1.urn.tbd.params.xml.ns.yang.nodes.rev20140309; import java.util.List; import org.onosproject.yang.gen.v1.urn.tbd.params.xml.ns.yang.nodes.rev20140309.network.Networklist; /** * Abstraction of an entity which represents the functionality of network. */ public interface Network { /** * Returns the attribute networklist. * * @return networklist list of networklist */ List<Networklist> networklist(); /** * Sets the attribute networklist. * * @param networklist list of networklist */ void networklist(List<Networklist> networklist); /** * Adds to the list of networklist. * * @param addTo value of networklist */ void addToNetworklist(Networklist addTo); } File: NetworkOpParam.java package org.onosproject.yang.gen.v1.urn.tbd.params.xml.ns.yang.nodes.rev20140309; import com.google.common.base.MoreObjects; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import org.onosproject.yang.gen.v1.urn.tbd.params.xml.ns.yang.nodes.rev20140309.network.Networklist; import org.onosproject.yang.model.InnerModelObject; /** * Represents the implementation of network. * * <p> * valueLeafFlags identify the leafs whose value are explicitly set * Applicable in protocol edit and query operation. * </p> */ public class NetworkOpParam extends InnerModelObject implements Network { protected List<Networklist> networklist; @Override public List<Networklist> networklist() { return networklist; } @Override public void networklist(List<Networklist> networklist) { this.networklist = networklist; } @Override public void addToNetworklist(Networklist addTo) { if (networklist == null) { networklist = new ArrayList<>(); } networklist.add(addTo); } @Override public int hashCode() { return Objects.hash(networklist); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof NetworkOpParam) { NetworkOpParam other = (NetworkOpParam) obj; return Objects.equals(networklist, other.networklist); } return false; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .omitNullValues() .add("networklist", networklist) .toString(); } /** * Creates an instance of networkOpParam. */ public NetworkOpParam() { } @Override public void addAugmentation(InnerModelObject obj) { } @Override public void removeAugmentation(InnerModelObject obj) { } @Override public Map<Class<? extends InnerModelObject>, InnerModelObject> augmentations() { return null; } @Override public <T extends InnerModelObject> T augmentation(Class<T> c) { return null; } } |
...
Sub Module
Overview
The “submodule” groups all the statements that belongs to the submodule together. The "submodule" statement's argument is the name of the submodule, followed by a block of sub statements.
...
Info |
---|
Code generation will be same as module. |
...
Prefix
Overview
Prefix is used to define prefix associated with module. It is used as a hint to other module developers when they import our module.
...
Code Block | ||
---|---|---|
| ||
File : Uuid.java package org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev20100924.ietfyangtypes; import java.util.Objects; import com.google.common.base.MoreObjects; public final class Uuid { private String string; private Uuid() { } public Uuid(String value) { this.string = value; } public static Uuid of(String value) { return new Uuid(value); } public String string() { return string; } @Override public int hashCode() { return Objects.hash(string); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof Uuid) { Uuid other = (Uuid) obj; return Objects.equals(string, other.string); } return false; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .add("string", string) .toString(); } public static Uuid fromString(String valInString) { try { String tmpVal = (valInString); return of(tmpVal); } catch (Exception e) { } return null; } } File : DefaultCont1.java package org.onosproject.yang.gen.v1.sfc.flowclassifier.rev20160524.flowclassifier; import com.google.common.base.MoreObjects; import java.util.BitSet; import java.util.Objects; import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev20130715.ietfyangtypes.Uuid; import org.onosproject.yang.model.InnerModelObject; /** * Represents the implementation of cont1. * * <p> * valueLeafFlags identify the leafs whose value are explicitly set * Applicable in protocol edit and query operation. * </p> */ public class DefaultCont1 extends InnerModelObject implements Cont1 { protected Uuid id; protected BitSet valueLeafFlags = new BitSet(); @Override public Uuid id() { return id; } @Override public BitSet valueLeafFlags() { return valueLeafFlags; } @Override public void id(Uuid id) { valueLeafFlags.set(LeafIdentifier.ID.getLeafIndex()); this.id = id; } @Override public int hashCode() { return Objects.hash(id, valueLeafFlags); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof DefaultCont1) { DefaultCont1 other = (DefaultCont1) obj; return Objects.equals(id, other.id) && Objects.equals(valueLeafFlags, other.valueLeafFlags); } return false; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .omitNullValues() .add("id", id) .add("valueLeafFlags", valueLeafFlags) .toString(); } /** * Creates an instance of defaultCont1. */ public DefaultCont1() { } @Override public boolean isLeafValueSet(LeafIdentifier leaf) { return valueLeafFlags.get(leaf.getLeafIndex()); } } |
Include
Overview
A module uses a include statement to include sub-module that belongs to module. The argument is the name of sub-module. Modules are only allowed to include sub-module that belongs to module, as defined by belongs-to statement. When a module includes a submodule, it incorporates the contents of the submodule into the node hierarchy of the module.
...
Code Block | ||
---|---|---|
| ||
File : Connection.java package org.onosproject.yang.gen.v1.http.test.example.com.test; import org.onosproject.yang.gen.v1.http.test.example.com.test.connection.Destination; import org.onosproject.yang.gen.v1.http.test.example.com.test.connection.Source; /** * Abstraction of an entity which represents the functionality of connection. */ public interface Connection { /** * Returns the attribute source. * * @return source value of source */ Source source(); /** * Returns the attribute destination. * * @return destination value of destination */ Destination destination(); /** * Sets the attribute source. * * @param source value of source */ void source(Source source); /** * Sets the attribute destination. * * @param destination value of destination */ void destination(Destination destination); } |
Choice and case
Overview
The choice statement defines a set of alternatives, only one of which may exist at any one time. The argument is an identifier, followed by a block of sub-statements that holds detailed choice information.
...
The "type" statement takes as an argument a string that is the name of a YANG built-in type or a derived type, followed by an optional block of sub statements that are used to put further restrictions on the type.
Java mapping
...
YANG | Description | JAVA |
---|---|---|
binary | Any binary data | byte[] |
bits | A set of bits or flags | BitSet in container class (A enum class for bits leaf) |
boolean | "True" or "false" | boolean |
decimal64 | 64-bit signed decimal number | BigDecimal |
empty | A leaf that does not have any value | boolean |
enumeration | Enumerated strings | Enum class will be generated |
identityref | A reference to an abstract identity | To be implemented |
instance-identifier | References a data tree node | String |
int8 | 8-bit signed integer | byte |
int16 | 16-bit signed integer | short |
int32 | 32-bit signed integer | int |
int64 | 64-bit signed integer | long |
leafref | A reference to a leaf instance | The type of referenced leaf/leaf-list will be used |
string | Human-readable string | String |
uint8 | 8-bit unsigned integer | short |
uint16 | 16-bit unsigned integer | int |
uint32 | 32-bit unsigned integer | long |
uint64 | 64-bit unsigned integer | BigInteger |
union | Choice of member types | Union class will be generated |
Example
Code Block | ||
---|---|---|
| ||
leaf one { type string; } leaf two { type int32; } leaf-list three { type boolean; } leaf-list four { type int16; } leaf mybits { type bits { bit disable-nagle { position 0; } bit auto-sense-speed { position 1; } bit Mb-only { position 2; } } default "auto-sense-speed"; } |
Code Block | ||
---|---|---|
| ||
File : Test.java package org.onosproject.yang.gen.v1.http.huawei.com; import java.util.BitSet; import java.util.List; /** * Abstraction of an entity which represents the functionality of test. */ public interface Test { /** * Identify the leaf of Test. */ public enum LeafIdentifier implements org.onosproject.yang.model.LeafIdentifier{ ONE(1), /** * Represents two. */ TWO(2), /** * Represents mybits. */ MYBITS(3), /** * Represents three. */ THREE(4), /** * Represents four. */ FOUR(5); private int leafIndex; public int getLeafIndex() { return leafIndex; } LeafIdentifier(int value) { this.leafIndex = value; } } /** * Returns the attribute one. * * @return one value of one */ String one(); /** * Returns the attribute two. * * @return two value of two */ int two(); /** * Returns the attribute mybits. * * @return mybits value of mybits */ BitSet mybits(); /** * Returns the attribute three. * * @return three list of three */ List<Boolean> three(); /** * Returns the attribute four. * * @return four list of four */ List<Short> four(); /** * Returns the attribute valueLeafFlags. * * @return valueLeafFlags value of valueLeafFlags */ BitSet valueLeafFlags(); /** * Sets the attribute one. * * @param one value of one */ void one(String one); /** * Sets the attribute two. * * @param two value of two */ void two(int two); /** * Sets the attribute mybits. * * @param mybits value of mybits */ void mybits(BitSet mybits); /** * Sets the attribute three. * * @param three list of three */ void three(List<Boolean> three); /** * Sets the attribute four. * * @param four list of four */ void four(List<Short> four); /** * Adds to the list of three. * * @param addTo value of three */ void addToThree(Boolean addTo); /** * Adds to the list of four. * * @param addTo value of four */ void addToFour(Short addTo); /** * Checks if the leaf value is set. * * @param leaf leaf whose value status needs to checked * @return result of leaf value set in object */ boolean isLeafValueSet(LeafIdentifier leaf); } File : TestOpParam package org.onosproject.yang.gen.v1.http.huawei.com; import com.google.common.base.MoreObjects; import java.util.ArrayList; import java.util.BitSet; import java.util.List; import java.util.Map; import java.util.Objects; import org.onosproject.yang.model.InnerModelObject; /** * Represents the implementation of test. * * <p> * valueLeafFlags identify the leafs whose value are explicitly set * Applicable in protocol edit and query operation. * </p> */ public class TestOpParam extends InnerModelObject implements Test { protected String one; protected int two; protected BitSet mybits; protected List<Boolean> three; protected List<Short> four; protected BitSet valueLeafFlags = new BitSet(); @Override public String one() { return one; } @Override public int two() { return two; } @Override public BitSet mybits() { return mybits; } @Override public List<Boolean> three() { return three; } @Override public List<Short> four() { return four; } @Override public BitSet valueLeafFlags() { return valueLeafFlags; } @Override public void one(String one) { valueLeafFlags.set(LeafIdentifier.ONE.getLeafIndex()); this.one = one; } @Override public void two(int two) { valueLeafFlags.set(LeafIdentifier.TWO.getLeafIndex()); this.two = two; } @Override public void mybits(BitSet mybits) { valueLeafFlags.set(LeafIdentifier.MYBITS.getLeafIndex()); this.mybits = mybits; } @Override public void three(List<Boolean> three) { valueLeafFlags.set(LeafIdentifier.THREE.getLeafIndex()); this.three = three; } @Override public void four(List<Short> four) { valueLeafFlags.set(LeafIdentifier.FOUR.getLeafIndex()); this.four = four; } @Override public void addToThree(Boolean addTo) { if (three == null) { three = new ArrayList<>(); } three.add(addTo); } @Override public void addToFour(Short addTo) { if (four == null) { four = new ArrayList<>(); } four.add(addTo); } @Override public int hashCode() { return Objects.hash(one, two, mybits, three, four, valueLeafFlags); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof TestOpParam) { TestOpParam other = (TestOpParam) obj; return Objects.equals(one, other.one) && Objects.equals(two, other.two) && Objects.equals(mybits, other.mybits) && Objects.equals(three, other.three) && Objects.equals(four, other.four) && Objects.equals(valueLeafFlags, other.valueLeafFlags); } return false; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .omitNullValues() .add("one", one) .add("two", two) .add("mybits", mybits) .add("three", three) .add("four", four) .add("valueLeafFlags", valueLeafFlags) .toString(); } /** * Creates an instance of testOpParam. */ public TestOpParam() { } @Override public boolean isLeafValueSet(LeafIdentifier leaf) { return valueLeafFlags.get(leaf.getLeafIndex()); } @Override public void addAugmentation(InnerModelObject obj) { } @Override public void removeAugmentation(InnerModelObject obj) { } @Override public Map<Class<? extends InnerModelObject>, InnerModelObject> augmentations() { return null; } @Override public <T extends InnerModelObject> T augmentation(Class<T> c) { return null; } } |
Typedef
Overview
Typedef is user defined type for his implementation. It has the base type which is must for typedef. To give more information about the typedef there should be sub statements to describe it. Unit statement is optional for typedef which give info about the unit of the type. Default is like a value which will be assigned to the typedef if no value is given.default value should follow all restriction defined for the base-type.
...
Code Block | ||
---|---|---|
| ||
File : TunnelType.java package org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.ietfnetwork; /** * Represents the implementation of tunnelType. */ public abstract class TunnelType { /** * Returns the attribute tunnel-type. * * @return tunnel-type value of tunnel-type */ public static String tunnelTypeToString() { return "tunnel-type"; } /** * Returns the object of tunnelType fromString input String tunnelType. * * @param valInString value of input String * @return tunnelType */ public static Class fromString(String valInString) { if (valInString.equals("tunnel-type")) { return TunnelType.class; } throw new IllegalArgumentException("not a valid input element"); } } File : NetworkId.java package org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.ietfnetwork; import java.util.BitSet; /** * Abstraction of an entity which represents the functionality of networkId. */ public interface NetworkId { /** * Identify the leaf of NetworkId. */ public enum LeafIdentifier implements org.onosproject.yang.model.LeafIdentifier{ /** * Represents leafNetworkId. */ LEAFNETWORKID(1); private int leafIndex; public int getLeafIndex() { return leafIndex; } LeafIdentifier(int value) { this.leafIndex = value; } } /** * Returns the attribute leafNetworkId. * * @return leafNetworkId value of leafNetworkId */ Class<? extends TunnelType> leafNetworkId(); /** * Returns the attribute valueLeafFlags. * * @return valueLeafFlags value of valueLeafFlags */ BitSet valueLeafFlags(); /** * Sets the attribute leafNetworkId. * * @param leafNetworkId value of leafNetworkId */ void leafNetworkId(Class<? extends TunnelType> leafNetworkId); /** * Checks if the leaf value is set. * * @param leaf leaf whose value status needs to checked * @return result of leaf value set in object */ boolean isLeafValueSet(LeafIdentifier leaf); } |
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.
...
Code Block | ||
---|---|---|
| ||
File : Bits.java package org.onosproject.yang.gen.v1.http.huawei.com.test.mybits; import java.util.BitSet; import java.util.regex.Pattern; /** * Represents ENUM data of bits. */ public enum Bits { /** * Represents disable-nagle. */ DISABLE_NAGLE(0, "disable-nagle"), /** * Represents auto-sense-speed. */ AUTO_SENSE_SPEED(1, "auto-sense-speed"), /** * Represents mb-only. */ MB_ONLY(2, "Mb-only"); private int bits; private String schemaName; /** * Creates an instance of bits. * * @param bits value of bits */ Bits(int bits, String schemaName) { this.bits = bits; this.schemaName = schemaName; } /** * Returns the object of bits for. * * @param value value of bits for * @return bits for */ public static Bits of(int value) { switch (value) { case 0: return Bits.DISABLE_NAGLE; case 1: return Bits.AUTO_SENSE_SPEED; case 2: return Bits.MB_ONLY; default : throw new IllegalArgumentException("not a valid input element"); } } /** * Returns the object of bits for. * * @param value value of bits for * @return bits for */ public static Bits of(String value) { switch (value) { case "disable-nagle": return Bits.DISABLE_NAGLE; case "auto-sense-speed": return Bits.AUTO_SENSE_SPEED; case "Mb-only": return Bits.MB_ONLY; default : throw new IllegalArgumentException("not a valid input element"); } } /** * Returns the attribute bits. * * @return bits value of bits */ public int bits() { return bits; } /** * Returns the object of bits fromString input String bits. * * @param valInString value of input String * @return bits */ public static BitSet fromString(String valInString) { BitSet tmpVal = new BitSet(); String[] bitNames = valInString.trim().split(Pattern.quote(" ")); for (String bitName : bitNames) { Bits bits = of(bitName); if (bits != null) { tmpVal.set(bits.bits()); } } if (tmpVal.isEmpty()) { throw new IllegalArgumentException("not a valid input element"); } return tmpVal; } public static String toString(BitSet bits) { StringBuilder sBuild = new StringBuilder(""); if (bits.get(Bits.DISABLE_NAGLE.bits())) { sBuild.append("disable-nagle"); sBuild.append(" "); } if (bits.get(Bits.AUTO_SENSE_SPEED.bits())) { sBuild.append("auto-sense-speed"); sBuild.append(" "); } if (bits.get(Bits.MB_ONLY.bits())) { sBuild.append("Mb-only"); sBuild.append(" "); } return sBuild.toString(); } } File: MyBits.java package org.onosproject.yang.gen.v1.http.huawei.com.test; import java.util.BitSet; import org.onosproject.yang.gen.v1.http.huawei.com.test.mybits.Bits; import java.util.Objects; /** * Represents the implementation of myBits. */ public final class MyBits { private BitSet bits; /** * Creates an instance of myBits. */ private MyBits() { } /** * Creates an instance of bits. * * @param bits value of bits */ public MyBits(BitSet bits) { this.bits = bits; } /** * Returns the object of myBits for type bits. * * @param value value of myBits for type bits * @return myBits for type bits */ public static MyBits of(BitSet value) { return new MyBits(value); } /** * Returns the attribute bits. * * @return bits value of bits */ public BitSet bits() { return bits; } /** * Sets the attribute bits. * * @param bits value of bits */ public void bits(BitSet bits) { this.bits = 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(bits); } /** * Returns the object of myBits fromString input String myBits. * * @param valInString value of input String * @return myBits */ public static MyBits fromString(String valInString) { try { BitSet tmpVal = Bits.fromString(valInString); return of(tmpVal); } catch (Exception e) { throw new IllegalArgumentException("not a valid input element"); } } } |
Binary
Overview
The binary built-in type represents any binary data, i.e., a sequence of octets.
...
The Minimum and Maximum decimal64 value table for each fraction-digit value.
fraction-digits | min | max |
---|---|---|
1 | -922337203685477580.8 | 922337203685477580.7 |
2 | -92233720368547758.08 | 92233720368547758.07 |
3 | -9223372036854775.808 | 9223372036854775.807 |
4 | -922337203685477.5808 | 922337203685477.5807 |
5 | -92233720368547.75808 | 92233720368547.75807 |
6 | -9223372036854.775808 | 9223372036854.775807 |
7 | -922337203685.4775808 | 922337203685.4775807 |
8 | -92233720368.54775808 | 92233720368.54775807 |
9 | -9223372036.854775808 | 9223372036.854775807 |
10 | -922337203.6854775808 | 922337203.6854775807 |
11 | -92233720.36854775808 | 92233720.36854775807 |
12 | -9223372.036854775808 | 9223372.036854775807 |
13 | -922337.2036854775808 | 922337.2036854775807 |
14 | -92233.72036854775808 | 92233.72036854775807 |
15 | -9223.372036854775808 | 9223.372036854775807 |
16 | -922.3372036854775808 | 922.3372036854775807 |
17 | -92.23372036854775808 | 92.23372036854775807 |
18 | -9.223372036854775808 | 9.223372036854775807 |
Java mapping
BigDecimal is used to store decimal64 value during code generation.
Example
...
Code Block | ||
---|---|---|
| ||
File : test.yang module Test { yang-version 1; namespace http://huawei.com; prefix Ant; typedef MyDecimal { type decimal64 { fraction-digits 2; range "1 .. 3.14 | 10 | 20..max"; } } } |
Code Block | ||
---|---|---|
| ||
File: MyDecimal.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160718.test; import java.math.BigDecimal; import java.util.Objects; import com.google.common.base.MoreObjects; public final class MyDecimal { private BigDecimal decimal64; private MyDecimal() { } public MyDecimal(BigDecimal value) { this.decimal64 = value; } public static MyDecimal of(BigDecimal value) { return new MyDecimal(value); } public BigDecimal decimal64() { return decimal64; } @Override public int hashCode() { return Objects.hash(decimal64); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof MyDecimal) { MyDecimal other = (MyDecimal) obj; return Objects.equals(decimal64, other.decimal64); } return false; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .add("decimal64", decimal64) .toString(); } public static MyDecimal fromString(String valInString) { try { BigDecimal tmpVal = new BigDecimal(valInString); return of(tmpVal); } catch (Exception e) { } return null; } } |
Unknown Statement
Overview
...