Node extends NetworkElement { public void setSiteName (String site) { if ((site == null) && (this.siteName == null)) return; if (site == null) { if (this.siteName != null) { final SortedSet<Node> nodesOldSiteNames = netPlan.cache_nodesPerSiteName.get(this.siteName); nodesOldSiteNames.remove(this); if (nodesOldSiteNames.isEmpty()) netPlan.cache_nodesPerSiteName.remove(this.siteName); } this.siteName = null; } else { if (site.equals(this.siteName)) return; if (this.siteName != null) { final SortedSet<Node> nodesOldSiteNames = netPlan.cache_nodesPerSiteName.get(this.siteName); nodesOldSiteNames.remove(this); if (nodesOldSiteNames.isEmpty()) netPlan.cache_nodesPerSiteName.remove(this.siteName); } SortedSet<Node> nodesThisNewSiteName = netPlan.cache_nodesPerSiteName.get(site); if (nodesThisNewSiteName == null) { nodesThisNewSiteName = new TreeSet<> (); netPlan.cache_nodesPerSiteName.put(site, nodesThisNewSiteName); } nodesThisNewSiteName.add(this); this.siteName = site; } } protected  Node(NetPlan netPlan , long id , int index , double xCoord, double yCoord, String name, AttributeMap attributes); void setSiteName(String site); String getSiteName(); void setPopulation(double population); double getPopulation(); double getEgressOfferedTraffic(NetworkLayer ... optionalLayerParameter); double getIncomingLinksTraffic(NetworkLayer ... optionalLayerParameter); double getOutgoingLinksTraffic(NetworkLayer ... optionalLayerParameter); double getIncomingLinksCapacity(NetworkLayer ... optionalLayerParameter); double getOutgoingLinksCapacity(NetworkLayer ... optionalLayerParameter); double getIngressOfferedTraffic(NetworkLayer ... optionalLayerParameter); double getEgressOfferedMulticastTraffic(NetworkLayer ... optionalLayerParameter); double getIngressOfferedMulticastTraffic(NetworkLayer ... optionalLayerParameter); void removeAllForwardingRules(NetworkLayer ... optionalLayerParameter); double getEgressCarriedTraffic(NetworkLayer ... optionalLayerParameter); double getIngressCarriedTraffic(NetworkLayer ... optionalLayerParameter); double getEgressCarriedMulticastTraffic(NetworkLayer ... optionalLayerParameter); double getIngressCarriedMulticastTraffic(NetworkLayer ... optionalLayerParameter); SortedSet<Node> getInNeighbors(NetworkLayer ... optionalLayerParameter); SortedSet<Node> getOutNeighbors(NetworkLayer ... optionalLayerParameter); SortedSet<Node> getOutNeighborsAllLayers(); SortedSet<Node> getInNeighborsAllLayers(); Point2D getXYPositionMap(String ...layout); void setXYPositionMap(Point2D pos , String ...layout); boolean isUp(); boolean isDown(); SortedSet<Link> getIncomingLinks(NetworkLayer ... optionalLayerParameter); SortedSet<NetworkLayer> getWorkingLayers(); boolean isWorkingAtLayer(NetworkLayer layer); boolean isIsolated(); SortedSet<Link> getOutgoingLinks(NetworkLayer ... optionalLayerParameter); SortedSet<Link> getOutgoingLinksAllLayers(); SortedSet<Link> getIncomingLinksAllLayers(); SortedSet<Demand> getOutgoingDemandsAllLayers(); SortedSet<Demand> getIncomingDemandsAllLayers(); SortedSet<MulticastDemand> getOutgoingMulticastDemandsAllLayers(); SortedSet<MulticastDemand> getIncomingMulticastDemandsAllLayers(); SortedSet<Demand> getIncomingDemands(NetworkLayer ... optionalLayerParameter); boolean setFailureState(boolean setAsUp); SortedSet<Route> getIncomingRoutes(NetworkLayer ... optionalLayerParameter); SortedSet<MulticastTree> getIncomingMulticastTrees(NetworkLayer ... optionalLayerParameter); SortedSet<Route> getOutgoingRoutes(NetworkLayer ... optionalLayerParameter); SortedSet<MulticastTree> getOutgoingMulticastTrees(NetworkLayer ... optionalLayerParameter); SortedSet<Demand> getOutgoingDemands(NetworkLayer ... optionalLayerParameter); SortedSet<MulticastDemand> getIncomingMulticastDemands(NetworkLayer ... optionalLayerParameter); SortedSet<MulticastDemand> getOutgoingMulticastDemands(NetworkLayer ... optionalLayerParameter); SortedSet<Route> getAssociatedRoutes(NetworkLayer ... optionalLayerParameter); SortedSet<Route> getExpressRoutes(NetworkLayer ... optionalLayerParameter); SortedSet<MulticastTree> getAssociatedMulticastTrees(NetworkLayer ... optionalLayerParameter); SortedSet<SharedRiskGroup> getSRGs(); SortedSet<Resource> getResources(String ... type); void remove(); @Override String toString(); SortedMap<Pair<Demand,Link>,Double> getForwardingRules(NetworkLayer ... optionalLayerParameter); SortedMap<Pair<Demand,Link>,Double> getForwardingRules(Demand demand); URL getUrlNodeIcon(NetworkLayer layer); double getNodeIconRelativeSize(NetworkLayer layer); void setUrlNodeIcon(NetworkLayer layer , URL url , Double relativeSize); void removeUrlNodeIcon(NetworkLayer layer); SortedSet<String> getPlanningDomains(); void removeFromPlanningDomain(String planningDomain); void addToPlanningDomain(String planningDomain);  }
@Test public void testSetSiteName() { assertEquals (np.getSiteNames() , Sets.newHashSet("s12" , "s3")); n3.setSiteName("s4"); assertEquals (np.getSiteNames() , Sets.newHashSet("s12" , "s4")); n3.setSiteName(null); assertEquals (np.getSiteNames() , Sets.newHashSet("s12")); assertEquals(n3.getSiteName() , null); n1.setSiteName("s1"); assertEquals(n1.getSiteName() , "s1"); }