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.
...
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.
Container statement is mapped to java as
...
| Code Block | ||
|---|---|---|
| ||
File : acme-system.yang
module acme-system {
namespace "http://acme.example.com/system";
prefix "acme";
organization "ACME Inc.";
contact "joe@acme.example.com";
description
"The .
module for entities implementing the ACME system.";
revision .2007-06-09 {
description "Initial revision.";
}
.
container holdersystem {
container systemlogin {
leaf host-namemessage {
type string;
} description
leaf-list domain-search {
"Message given at start of login session";
type string;
}
}
}
.
}.
}.
} |
| Code Block | ||
|---|---|---|
| ||
File : SystemLogin.java public interface SystemLogin extends AugmentationHolder { String hostName(); List<String> domainSearchmessage(); interface SystemBuilderLoginBuilder { String hostNamemessage(); List<String>LoginBuilder domainSearch(); SystemBuilder hostName(message(String hostNamemessage); SystemBuilder domainSearch(List<String> domainSearch); System Login build(); } } File : SystemBuilder.java public class SystemBuilderLoginBuilder implements SystemLogin.SystemBuilderLoginBuilder { private String hostNamemessage; private List<String> domainSearch;@Override public String hostNamemessage() { return hostNamemessage; } public List<String> domainSearch() { return domainSearch; } public SystemBuilder hostName(String hostName@Override public LoginBuilder message(String message) { this.hostNamemessage = hostNamemessage; return this; } public SystemBuilder domainSearch(List<String> domainSearch) {@Override public Login this.domainSearch = domainSearch;build() { return new LoginImpl(this); } public LoginBuilder() .{ . .} public final class SystemImplLoginImpl implements SystemLogin { . private List<AugmentedInfo> augmentedInfoList = . new ArrayList<>(); . private String message; @Override public String message() { return } } File : Holder.java public interface Holder extends AugmentationHolder message; } @Override public int hashCode() { System system(); interface HolderBuilder { System system return Objects.hash(message); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof LoginImpl) { LoginImpl other = (LoginImpl) obj; return Objects.equals(message, other.message); } return false; } @Override public String toString() { return MoreObjects.toStringHelper(getClass()) .add("message", message) .toString(); HolderBuilder system(System system);} Holderpublic buildLoginImpl(LoginBuilder builderObject); { } } File : HolderBuilder.java public class HolderBuilder implements Holder.HolderBuilder { this.message private System system= builderObject.message(); public System system() {} return system;@Override } public HolderBuildervoid systemaddAugmentation(SystemAugmentedInfo systemvalue) { this.system = system getAugmentedInfoList().add(value); } return this; @Override } public HolderList<AugmentedInfo> buildgetAugmentedInfoList() { return new HolderImpl(this)augmentedInfoList; } } . .@Override . public final class HolderImpl implements Holdervoid removeAugmentation() { . getAugmentedInfoList().clear(); . } } } |
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.
...