...
- Service interface
It includes:
a) java methods corresponding to the YANG RPC (Refer RPC section for more details)
b) If module contains notification, generated service interface will extend listener service (refer notification for more details) - Manager class
It includes:
a ) Activate/Deactivate methods
b) If module contains child data nodes, getters and setters for those nodes will be generated for app developers to implement.
c)If module contains notification, generated manager class will extend ListenerRegistry(refer notification for more details) .
The manager class implements the service interface. The name of service interface and manager class is <module_name>Service.java and <module_name>Manager.java.
Example
| Code Block | ||||||
|---|---|---|---|---|---|---|
|
|
| ||||
: File : network.yang module network { yang-version 1; namespace "urn:TBD:params:xml:ns:yang:nodes"; prefix nd; organization "TBD"; contact "WILL-BE-DEFINED-LATER"; description "This module defines a common base model for a collection of nodes in a network. Node definitions s are further used in network topologies and inventories."; revision 2014-03-09 { description "Initial revision."; reference "draft-clemm-i2rs-yang-network-topo-04"; } list networklist { key "network-id"; leaf network-id { type string; } leaf server-provided { type boolean; config false; } } …. } |
| Code Block | ||
|---|---|---|
| ||
Generated JAVA files : File : NetworkService.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; public interface NetworkService { List<Networklist> getNetworklist(); void setNetworklist(List<Networklist> networklist); } File : NetworkManager.java package org.onosproject.yang.gen.v1.urn.tbd.params.xml.ns.yang.nodes.rev20140309; import java.util.List; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; import org.apache.felix.scr.annotations.Service; import org.onosproject.yang.gen.v1.urn.tbd.params.xml.ns.yang.nodes.rev20140309.network.Networklist; import org.slf4j.Logger; import static org.slf4j.LoggerFactory.getLogger; @Component (immediate = true) @Service public class NetworkManager implements NetworkService { private final Logger log = getLogger(getClass()); @Activate public void activate() { //TODO: YANG utils generated code log.info("Started"); } @Deactivate public void deactivate() { //TODO: YANG utils generated code log.info("Stopped"); } @Override public List<Networklist> getNetworklist() { //TODO: YANG utils generated code return null; } @Override public void setNetworklist(List<Networklist> networklist) { //TODO: YANG utils generated code } } |
...
Submodule mapping to java is same as module and files with be generated in module’s namespace.
Example
| Code Block | ||||
|---|---|---|---|---|
|
| |||
File File: File : acme-system.yang module acme-system { namespace "http://yang-central.org/ns/example/acme"; prefix acme; include "acme-types"; leaf id { type string; } } File : acme-types.yang submodule acme-types { yang-version 1; belongs-to "acme-system" { prefix "acme"; } leaf access-timeout { type uint32; } leaf retries { type uint8; } } |
| Code Block | ||
|---|---|---|
| ||
Generated JAVA files :
File : AcmeSystemManager.java
package org.onosproject.yang.gen.v1.http.yang.central.org.ns.example.acme.rev20160526;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
@Component (immediate = true)
@Service
public class AcmeSystemManager implements AcmeSystemService {
private final Logger log = getLogger(getClass());
@Activate
public void activate() {
//TODO: YANG utils generated code
log.info("Started");
}
@Deactivate
public void deactivate() {
//TODO: YANG utils generated code
log.info("Stopped");
}
@Override
public String getId() {
//TODO: YANG utils generated code
return null;
}
@Override
public void setId(String id) {
//TODO: YANG utils generated code
}
}
File : AcmeSystemService.java
package org.onosproject.yang.gen.v1.http.yang.central.org.ns.example.acme.rev20160526;
public interface AcmeSystemService {
String getId();
void setId(String id);
}
File : AcmeTypesManager.java
package org.onosproject.yang.gen.v1.http.yang.central.org.ns.example.acme.rev20160526;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
@Component (immediate = true)
@Service
public class AcmeTypesManager implements AcmeTypesService {
private final Logger log = getLogger(getClass());
@Activate
public void activate() {
//TODO: YANG utils generated code
log.info("Started");
}
@Deactivate
public void deactivate() {
//TODO: YANG utils generated code
log.info("Stopped");
}
@Override
public long getAccessTimeout() {
//TODO: YANG utils generated code
return 0;
}
@Override
public short getRetries() {
//TODO: YANG utils generated code
return 0;
}
@Override
public void setAccessTimeout(long accessTimeout) {
//TODO: YANG utils generated code
}
@Override
public void setRetries(short retries) {
//TODO: YANG utils generated code
}
}
File : AcmeTypesService.java
package org.onosproject.yang.gen.v1.http.yang.central.org.ns.example.acme.rev20160526;
public interface AcmeTypesService {
long getAccessTimeout();
short getRetries();
void setAccessTimeout(long accessTimeout);
void setRetries(short retries);
} |
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.
...
In java leaf is converted to define variable with its respective java built-in type or derived type.
Example
...
| Code Block | ||
|---|---|---|
| ||
File : acme-system.yang
module acme-system {
.
.
.
leaf host-name {
type string;
}
} |
| Code Block | ||
|---|---|---|
| ||
File : AcmeSystemService.java
public interface AcmeSystemService {
String getHostName();
void setHostName(String hostName);
}
File: AcmeSystemManager.java
@Component (immediate = true)
@Service
public class AcmeSystemManager implements AcmeSystemService {
private final Logger log = getLogger(getClass());
@Activate
public void activate() {
//TODO: YANG utils generated code
log.info("Started");
}
@Deactivate
public void deactivate() {
//TODO: YANG utils generated code
log.info("Stopped");
}
@Override
public String getHostName() {
//TODO: YANG utils generated code
return null;
}
@Override
public void setHostName(String hostName) {
//TODO: YANG utils generated code
}
} |
...
Leaf-list
...
Overview
...
A leaf-list is also used for defining scalar variable, like leaf, but in an array of a particular type. The type of the variable can be either built-in type or a derived type.
Java mapping
In java leaf-list is stored in List, with respect to, java built-in type or derived type.
Example
| Code Block | ||
|---|---|---|
| ||
File : AcmeSystemService.java
public interface AcmeSystemService {
List<Short> getDomainSearch();
void setDomainSearch(List<Short> domainSearch);
} |
| Code Block | ||
|---|---|---|
| ||
File : AcmeSystemManager.java
@Component (immediate = true)
@Service
public class AcmeSystemManager implements AcmeSystemService {
private final Logger log = getLogger(getClass());
@Activate
public void activate() {
//TODO: YANG utils generated code
log.info("Started");
}
@Deactivate
public void deactivate() {
//TODO: YANG utils generated code
log.info("Stopped");
}
@Override
public List<Short> getDomainSearch() {
//TODO: YANG utils generated code
return null;
}
@Override
public void setDomainSearch(List<Short> domainSearch) {
//TODO: YANG utils generated code
}
} |
Container
...
Overview
Container is a holder that can hold many nodes within it. It is used for logically grouping certain set of nodes.
Java mapping
...
In java, container acts as a class which can hold information contained within. A class of the container is formed only when container has nodes in it. In addition to that, container's parent holder will have container class’s information.
Example
...
| Code Block | ||
|---|---|---|
| ||
File : acme-system.yang
module acme-system {
.
.
.
container holder {
container system {
leaf host-name {
type string;
}
leaf-list domain-search {
type string;
}
}
}
} |
| Code Block | ||
|---|---|---|
| ||
File : System.java
public interface System extends AugmentationHolder {
String hostName();
List<String> domainSearch();
interface SystemBuilder {
String hostName();
List<String> domainSearch();
SystemBuilder hostName(String hostName);
SystemBuilder domainSearch(List<String> domainSearch);
System build();
}
}
File : SystemBuilder.java
public class SystemBuilder implements System.SystemBuilder {
private String hostName;
private List<String> domainSearch;
public String hostName() {
return hostName;
}
public List<String> domainSearch() {
return domainSearch;
}
public SystemBuilder hostName(String hostName) {
this.hostName = hostName;
return this;
}
public SystemBuilder domainSearch(List<String> domainSearch) {
this.domainSearch = domainSearch;
return this;
}
.
.
.
public final class SystemImpl implements System {
.
.
.
}
}
File : Holder.java
public interface Holder extends AugmentationHolder {
System system();
interface HolderBuilder {
System system();
HolderBuilder system(System system);
Holder build();
}
}
File : HolderBuilder.java
public class HolderBuilder implements Holder.HolderBuilder {
private System system;
public System system() {
return system;
}
public HolderBuilder system(System system) {
this.system = system;
return this;
}
public Holder build() {
return new HolderImpl(this);
}
.
.
.
public final class HolderImpl implements Holder {
.
.
.
}
} |
...
List
Overview
List is also like container that can hold many nodes by logically grouping. The only difference is, list can have multiple instances whereas container has only one instance.
Java mapping
...
In java, list acts as a class which can hold information contained within. A class of the list is formed only when list has nodes in it. In addition to that, list's parent holder will have list information by creating the list information in java List so that many instances of the class can be stored in it.
Example
| Code Block | ||
|---|---|---|
| ||
File : acme-system.yang
module acme-system {
.
.
.
list user {
key "name";
list user {
key "name";
leaf name {
type string;
}
leaf full-name {
type string;
}
leaf class {
type string;
}
}
leaf name {
type string;
}
}
} |
| Code Block | ||
|---|---|---|
| ||
File : User.java
public interface User extends AugmentationHolder {
String name();
String fullName();
String yangAutoPrefixClass();
interface UserBuilder {
String name();
String fullName();
String yangAutoPrefixClass();
UserBuilder name(String name);
UserBuilder fullName(String fullName);
UserBuilder yangAutoPrefixClass(String yangAutoPrefixClass);
User build();
}
}
File : UserBuilder.java
public class UserBuilder implements User.UserBuilder {
private String name;
private String fullName;
private String yangAutoPrefixClass;
public String name() {
return name;
}
public String fullName() {
return fullName;
}
public String yangAutoPrefixClass() {
return yangAutoPrefixClass;
}
public UserBuilder name(String name) {
this.name = name;
return this;
}
public UserBuilder fullName(String fullName) {
this.fullName = fullName;
return this;
}
public UserBuilder yangAutoPrefixClass(String yangAutoPrefixClass) {
this.yangAutoPrefixClass = yangAutoPrefixClass;
return this;
}
.
.
.
public final class UserImpl implements User {
.
.
.
}
}
File : User.java
public interface User extends AugmentationHolder {
String name();
List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20160520.acmesystem.user.User> user();
interface UserBuilder {
String name();
List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20160520.acmesystem.user.User> user();
UserBuilder name(String name);
UserBuilder user(List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20160520.acmesystem.user.User> user);
User build();
}
}
File : UserBuilder.java
public class UserBuilder implements User.UserBuilder {
private String name;
private List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20160520.acmesystem.user.User> user;
public String name() {
return name;
}
public List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20160520.acmesystem.user.User> user() {
return user;
}
public UserBuilder name(String name) {
this.name = name;
return this;
}
public UserBuilder user(List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20160520.acmesystem.user.User> user) {
this.user = user;
return this;
}
.
.
.
public final class UserImpl implements User {
.
.
.
}
}
|
Grouping and uses
...
Overview
Grouping the nodes together, for reusing them at many places, can be done in YANG. Grouping the nodes is done by grouping statement and using those grouped nodes at different places is done by uses statement.
Java mapping
During YANG to java conversion, the nodes under grouping are completely copied, wherever uses is present. Later the java file generation takes place according to the new yang nodes added. Grouping and uses itself will not have any impact in java file generation.
Example
| Code Block | ||
|---|---|---|
| ||
File : Test.yang
module Test {
.
.
.
grouping Percentage {
leaf mark{
type String;
}
}
container classroom {
leaf student{
type String;
}
uses Percentage;
}
} |
...
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.
...
Interface file which extends choice marker interface
Builder class which implements the builder interface and impl class which implements the interface
- Impl class includes overridden methods, hashcode, equals, toString methods.
Example
| Code Block | ||||||
|---|---|---|---|---|---|---|
|
|
| ||||
:
File : link.yang
module link {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
container link {
choice interfaceType {
case ethernerType {
leaf ethernet { type string; }
}
case p2pType {
leaf p2p { type string; }
}
}
}
} |
| Code Block | ||
|---|---|---|
| ||
File : Generated JAVA files : File : InterfaceType.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160509.choicecasetest.link1; import org.onosproject.yangutils.translator.tojava.AugmentationHolder; public interface InterfaceType extends AugmentationHolder { } File : EthernerType.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160509.choicecasetest.link1.interfacetype; import org.onosproject.yang.gen.v1.http.huawei.com.rev20160509.choicecasetest.link1.InterfaceType; import org.onosproject.yangutils.translator.tojava.AugmentationHolder; public interface EthernerType extends AugmentationHolder, InterfaceType { String ethernet(); interface EthernerTypeBuilder { String ethernet(); EthernerTypeBuilder ethernet(String ethernet); EthernerType build(); } } File : EthernerTypeBuilder.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160509.choicecasetest.link1.interfacetype; import com.google.common.base.MoreObjects; import java.util.ArrayList; import java.util.List; import java.util.Objects; import org.onosproject.yangutils.translator.tojava.AugmentedInfo; public class EthernerTypeBuilder implements EthernerType.EthernerTypeBuilder { private String ethernet; @Override public String ethernet() { return ethernet; } @Override public EthernerTypeBuilder ethernet(String ethernet) { this.ethernet = ethernet; return this; } @Override public EthernerType build() { return new EthernerTypeImpl(this); } public EthernerTypeBuilder() { } public final class EthernerTypeImpl implements EthernerType { private String ethernet; @Override public String ethernet() { return ethernet; } public EthernerTypeImpl() { } public EthernerTypeImpl(EthernerTypeBuilder builderObject) { this.ethernet = builderObject.ethernet(); } } } |
RPC
Overview
RPCs are modeled with RPC statement. The input statement is used to define input parameters to the RPC and output statement is used to define output parameters to the RPC.
...
When input is present and no output statement.
When input has only one leaf/leaf-list. In this case method signature will have return type as “void” and member attribute with type of leaf.
When input has only one YANG construct. In this case method signature will have return type as “void” and a class will be generated for construct which will be used as the type of method’s attribute..
When input has multiple leaf/leaf-list/YANG construct, one class will be generated for input and that will be used as type of method’s attribute and return type will be void.
When no input and output statement is present.
When output has only one leaf/leaf-list. In this case method signature will have return type as type of leaf and no member attribute.
When output has only one YANG construct. In this case method signature will have return type as class which is generated for construct and no method attribute will be generated.
- When output has multiple leaf/leaf-list/YANG construct, one class will be generated for output and that will be used as type of method’s return type.
- When input is present and output statement is present.
When input has only one leaf/leaf-list and output has only leaf/leaf-list. In this case method signature will have return type as type of leaf/list of output and member attribute with type of leaf/leaf-lists type input.
When input has only one YANG construct and output has one YANG construct. In this case method signature will have return type as generated class of outputs construct and a class will be generated for inputs construct which will be used as the type of method’s attribute.
- When input has multiple leaf/leaf-list/YANG construct, and output has leaf/leaf-list/YANG construct one class will be generated for input and that will be used as type of method’s attribute and class will be generated for output which will be used as return type of method.
Example
| Code Block | ||||||
|---|---|---|---|---|---|---|
|
|
| ||||
:
File: sfc.yang
module Sfc {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
rpc SFP {
input {
leaf port {
type string;
}
}
output {
leaf path {
type string;
}
}
}
} |
| Code Block | ||
|---|---|---|
| ||
Generated JAVA files : File : SfcService.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160526; import org.onosproject.yang.gen.v1.http.huawei.com.rev20160526.sfc.sfp.SfpInput; import org.onosproject.yang.gen.v1.http.huawei.com.rev20160526.sfc.sfp.SfpOutput; public interface SfcService { SfpOutput sfp(SfpInput inputVar); } File : SfcManager.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160526; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; import org.apache.felix.scr.annotations.Service; import org.onosproject.yang.gen.v1.http.huawei.com.rev20160526.sfc.sfp.SfpInput; import org.onosproject.yang.gen.v1.http.huawei.com.rev20160526.sfc.sfp.SfpOutput; import org.slf4j.Logger; import static org.slf4j.LoggerFactory.getLogger; @Component (immediate = true) @Service public class SfcManager implements SfcService { private final Logger log = getLogger(getClass()); @Activate public void activate() { //TODO: YANG utils generated code log.info("Started"); } @Deactivate public void deactivate() { //TODO: YANG utils generated code log.info("Stopped"); } @Override public SfpOutput sfp(SfpInput inputVar) { //TODO: YANG utils generated code return null; } } File : SfpInput.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160526.sfc.sfp; public interface SfpInput { String port(); interface SfpInputBuilder { String port(); SfpInputBuilder port(String port); SfpInput build(); } } File : SfpinputBuilder.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160526.sfc.sfp; import com.google.common.base.MoreObjects; import java.util.Objects; public class SfpInputBuilder implements SfpInput.SfpInputBuilder { private String port; @Override public String port() { return port; } @Override public SfpInputBuilder port(String port) { this.port = port; return this; } @Override public SfpInput build() { return new SfpInputImpl(this); } public SfpInputBuilder() { } public final class SfpInputImpl implements SfpInput { private String port; @Override public String port() { return port; } @Override public int hashCode() { return Objects.hash(port); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof SfpInputImpl) { SfpInputImpl other = (SfpInputImpl) obj; return Objects.equals(port, other.port); } return false; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .add("port", port) .toString(); } public SfpInputImpl(SfpInputBuilder builderObject) { this.port = builderObject.port(); } } } File : Sfpoutput.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160526.sfc.sfp; public interface SfpOutput { String path(); interface SfpOutputBuilder { String path(); SfpOutputBuilder path(String path); SfpOutput build(); } } File : SfpOutputBuilder.java package org.onosproject.yang.gen.v1.http.huawei.com.rev20160526.sfc.sfp; import com.google.common.base.MoreObjects; import java.util.Objects; public class SfpOutputBuilder implements SfpOutput.SfpOutputBuilder { private String path; @Override public String path() { return path; } @Override public SfpOutputBuilder path(String path) { this.path = path; return this; } @Override public SfpOutput build() { return new SfpOutputImpl(this); } public SfpOutputBuilder() { } public final class SfpOutputImpl implements SfpOutput { private String path; @Override public String path() { return path; } @Override public int hashCode() { return Objects.hash(path); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof SfpOutputImpl) { SfpOutputImpl other = (SfpOutputImpl) obj; return Objects.equals(path, other.path); } return false; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .add("path", path) .toString(); } public SfpOutputImpl(SfpOutputBuilder builderObject) { this.path = builderObject.path(); } } } |
Notification
Overview
...
The "notification" statement is used to define a notification. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed notification information.
...
Manager Extends ListenerRegistry with event and eventListener.
Example
| Code Block | ||
|---|---|---|
| ||
File : ospf.yang
module ospf {
namespace "http://example.com/ospf";
prefix "ospf";
notification test {
leaf event-class {
type string;
}
leaf severity {
type string;
}
}
} |
| Code Block | ||
|---|---|---|
| ||
File : OspfManager.java package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; import org.apache.felix.scr.annotations.Service; import org.onosproject.event.ListenerRegistry; import org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf.OspfEvent; import org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf.OspfListener; import org.slf4j.Logger; import static org.slf4j.LoggerFactory.getLogger; @Component (immediate = true) @Service public class OspfManager extends ListenerRegistry<OspfEvent, OspfListener> implements OspfService { private final Logger log = getLogger(getClass()); @Activate public void activate() { //TODO: YANG utils generated code log.info("Started"); } @Deactivate public void deactivate() { //TODO: YANG utils generated code log.info("Stopped"); } } File : OspfService.java package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519; import org.onosproject.event.ListenerService; import org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf.OspfEvent; import org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf.OspfListener; public interface OspfService extends ListenerService<OspfEvent, OspfListener> { } File : OspfEvent.java package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160527.ospf; import org.onosproject.event.AbstractEvent; public class OspfEvent extends AbstractEvent<OspfEvent.Type, OspfEventSubject> { public enum Type { TEST } public OspfEvent(Type type, OspfEventSubject subject) { super(type, subject); } public OspfEvent(Type type, OspfEventSubject subject, long time) { super(type, subject, time); } } File : OspfEventSubject.java package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf; public class OspfEventSubject { private Test test; public Test test() { return test; } public void test(Test test) { this.test = test; } } File : OspfListener.java package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf; import org.onosproject.event.EventListener; public interface OspfListener extends EventListener<OspfEvent> { } File : Test.java package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf; import org.onosproject.yangutils.translator.tojava.AugmentationHolder; public interface Test extends AugmentationHolder { String eventClass(); String severity(); interface TestBuilder { String eventClass(); String severity(); TestBuilder eventClass(String eventClass); TestBuilder severity(String severity); Test build(); } } File : TestBuilder.java package org.onosproject.yang.gen.v1.http.example.com.ospf.rev20160519.ospf; import com.google.common.base.MoreObjects; import java.util.ArrayList; import java.util.List; import java.util.Objects; import org.onosproject.yangutils.translator.tojava.AugmentedInfo; public class TestBuilder implements Test.TestBuilder { private String eventClass; private String severity; @Override public String eventClass() { return eventClass; } @Override public String severity() { return severity; } @Override public TestBuilder eventClass(String eventClass) { this.eventClass = eventClass; return this; } @Override public TestBuilder severity(String severity) { this.severity = severity; return this; } @Override public Test build() { return new TestImpl(this); } public TestBuilder() { } public final class TestImpl implements Test { private List<AugmentedInfo> augmentedInfoList = new ArrayList<>(); private String eventClass; private String severity; @Override @Override public String eventClass() { return eventClass; } @Override public String severity() { return severity; } @Override public int hashCode() { return Objects.hash(eventClass, severity); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof TestImpl) { TestImpl other = (TestImpl) obj; return Objects.equals(eventClass, other.eventClass) && Objects.equals(severity, other.severity); } return false; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .add("eventClass", eventClass) .add("severity", severity) .toString(); } public TestImpl(TestBuilder builderObject) { this.eventClass = builderObject.eventClass(); this.severity = builderObject.severity(); } @Override public void addAugmentation(AugmentedInfo value) { getAugmentedInfoList().add(value); } @Override public List<AugmentedInfo> getAugmentedInfoList() { return augmentedInfoList; } @Override public void removeAugmentation() { getAugmentedInfoList().clear(); } } } |
...
Augment
Overview
Augment means “make (something) greater by adding to it; increase.” in yang augment adds some information in target node. Here in yang, container, list, choice, case, input, output, or notification node can come as a target node.
...