2 * Copyright © 2017 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.stubpce.topology;
11 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
12 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
13 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
15 import java.util.ArrayList;
16 import java.util.List;
20 * class to create Supernode
23 * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on
26 @JacksonXmlRootElement(localName = "super-node")
27 public class SuperNode {
29 @JacksonXmlProperty(localName = "super-node-id")
30 private String superNodeId;
31 /** list of elements cotaining in Supernode. */
32 @JacksonXmlElementWrapper(localName = "resources")
33 @JacksonXmlProperty(localName = "resource")
34 private List<Resource> resources;
37 * SuperNode constructor.
39 * @param supernodeid superNode Id
40 * @param resources List of Supernode elements
42 public SuperNode(@JacksonXmlProperty(localName = "super-node-id") final String supernodeid,
43 @JacksonXmlProperty(localName = "Spresource") final List<Resource> resources) {
44 setSuperNodeId(supernodeid);
45 setResources(resources);
49 * SuperNode constructor.
51 * @param supernodeid supernode Id
53 public SuperNode(String supernodeid) {
54 setSuperNodeId(supernodeid);
55 setResources(new ArrayList<Resource>());
59 *Test if Supernode contains
61 * @return true if XPDR present, false else
63 public boolean isXpdrSrgAbsent() {
64 boolean result = true;
66 if (resources.size() > 0) {
67 for (Resource resource : resources) {
68 String nodeId = resource.getNodeId();
70 if (nodeId.contains("XPDR")) {
73 if (nodeId.contains("SRG")) {
85 public List<Resource> getResources() {
89 public void setResources(List<Resource> resources) {
90 this.resources = resources;
93 public String getSuperNodeId() {
97 public void setSuperNodeId(String superNodeId) {
98 this.superNodeId = superNodeId;
102 public String toString() {
105 java.lang.String name = "SuperNode [";
106 java.lang.StringBuilder builder = new java.lang.StringBuilder(name);
107 if (superNodeId != null) {
108 builder.append("superNodeId=");
109 builder.append(superNodeId);
112 size = resources.size();
113 builder.append(", Resources [");
114 for (Resource tmp : resources) {
115 builder.append(tmp.toString());
118 builder.append(", ");
122 return builder.append(']').toString();