Link extends NetworkElement implements IMonitorizableElement { public void remove() { final boolean previousErrorHandling = ErrorHandling.DEBUG; ErrorHandling.DEBUG = false; checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); if (this.coupledLowerOrThisLayerDemand != null) this.coupledLowerOrThisLayerDemand.decouple(); else if (this.coupledLowerLayerMulticastDemand != null) this.coupledLowerLayerMulticastDemand.decouple(); if (bidirectionalPair != null) this.bidirectionalPair.bidirectionalPair = null; layer.cache_linksDown.remove (this); layer.cache_linksZeroCap.remove(this); netPlan.cache_id2LinkMap.remove(id); originNode.cache_nodeOutgoingLinks.remove (this); destinationNode.cache_nodeIncomingLinks.remove (this); layer.cache_nodePairLinksThisLayer.get(Pair.of(originNode, destinationNode)).remove(this); if (layer.cache_nodePairLinksThisLayer.get(Pair.of(originNode, destinationNode)).isEmpty()) layer.cache_nodePairLinksThisLayer.remove(Pair.of(originNode, destinationNode)); for (SharedRiskGroup srg : this.cache_nonDynamicSrgs) srg.linksIfNonDynamic.remove(this); for (MulticastTree tree : new LinkedList<MulticastTree> (cache_traversingTrees)) tree.remove (); for (Route route : new TreeSet<Route> (cache_traversingRoutes.keySet())) route.remove (); this.removeAllForwardingRules(); NetPlan.removeNetworkElementAndShiftIndexes (layer.links , index); for (String tag : tags) netPlan.cache_taggedElements.get(tag).remove(this); ErrorHandling.DEBUG = previousErrorHandling; final NetPlan npOld = this.netPlan; removeId(); if (ErrorHandling.isDebugEnabled()) npOld.checkCachesConsistency(); } protected  Link(NetPlan netPlan , long id , int index , NetworkLayer layer , Node originNode , Node destinationNode , double lengthInKm , double propagationSpeedInKmPerSecond , double capacity , AttributeMap attributes); Color getNominalColor(); void setNominalColor(Color nominalColor); double getOccupiedCapacityFromDemand(Demand d); Pair<Double,Double> getQosOccupationAndQosViolation(String qosType); Pair<Integer,Double> getQosTypePriorityAndMaxLinkUtilization(String qosType); SortedMap<String,Pair<Integer,Double>> getQosTypePriorityAndMaxLinkUtilizationMap(); void setQosTypePriorityAndMaxLinkUtilization(String qosType , int priority , double maxLinkUtilization); void removeQosTypePriorityAndMaxLinkUtilization(String qosType); SortedMap<String,Pair<Double,Double>> getPerQoSOccupationAndQosViolationMap(); SortedSet<Demand> getDemandsWithNonZeroForwardingRules(); Node getOriginNode(); Node getDestinationNode(); NetworkLayer getLayer(); Demand getCoupledDemand(); MulticastDemand getCoupledMulticastDemand(); boolean isCoupled(); SortedMap<Pair<Demand,Link>,Double> getForwardingRules(); double getCapacity(); void setCapacity(double newLinkCapacity); double getCarriedTraffic(); SortedSet<Route> getTraversingBackupRoutes(); int getNumberOfTraversingBackupRoutes(); double getUtilization(); double getOccupiedCapacity(); double getOccupiedCapacityOnlyBackupRoutes(); double getLengthInKm(); void setLengthInKm(double lengthInKm); double getPropagationSpeedInKmPerSecond(); double getMulticastCarriedTraffic(); double getMulticastOccupiedLinkCapacity(); void setPropagationSpeedInKmPerSecond(double speed); double getPropagationDelayInMs(); boolean isUp(); boolean isDown(); boolean isOversubscribed(); double getOversubscribedTraffic(); SortedSet<SharedRiskGroup> getSRGs(); SortedSet<Route> getTraversingRoutes(); SortedMap<Route,Integer> getTraversingRoutesAndMultiplicity(); int getNumberOfTraversingRoutes(); SortedSet<MulticastTree> getTraversingTrees(); int getNumberOfTraversingTrees(); int getNumberOfForwardingRules(); void coupleToLowerLayerDemand(Demand demand); Demand coupleToNewDemandCreated(NetworkLayer newDemandLayer , RoutingType routingTypeDemand); void removeAllForwardingRules(); Link getBidirectionalPair(); void setBidirectionalPair(Link e); boolean isBidirectional(); Link createBidirectionalPair(); void remove(); boolean setFailureState(boolean setAsUp); @Override String toString(); SortedSet<String> getQosViolated(); boolean isQoSViolated(String qosType); Triple<SortedSet<Demand>,SortedSet<Demand>,SortedSet<MulticastDemand>> getDemandsPotentiallyTraversingThisLink(); Triple<SortedMap<Demand,SortedSet<Link>>,SortedMap<Demand,SortedSet<Link>>,SortedMap<Pair<MulticastDemand,Node>,SortedSet<Link>>> getLinksThisLayerPotentiallyCarryingTrafficTraversingThisLink(); Triple<SortedMap<Demand,SortedSet<Link>>,SortedMap<Demand,SortedSet<Link>>,SortedMap<Pair<MulticastDemand,Node>,SortedSet<Link>>> getLinksDownPropagationPotentiallyCarryingTrafficTraversingThisLink(); boolean isCoupledInSameLayer(); boolean isCoupledInDifferentLayer(); void decouple(); @Override TrafficSeries getMonitoredOrForecastedCarriedTraffic(); @Override void setMonitoredOrForecastedCarriedTraffic(TrafficSeries newTimeSeries); @Override double getCurrentTrafficToAddMonitSample(); @Override boolean isPossibleToSetCurrentTrafficAsGivenMonitSample(); @Override void setCurrentTrafficToGivenMonitSample(double traffic); @Override Optional<TrafficPredictor> getTrafficPredictor(); @Override void setTrafficPredictor(TrafficPredictor tp); @Override void removeTrafficPredictor();  }
@Test public void testRemove() { List<Link> lower = new ArrayList<Link> (np.getLinks(lowerLayer)); List<Link> upper = new ArrayList<Link> (np.getLinks(upperLayer)); link12.remove(); lower.remove(link12); assertEquals (lower , np.getLinks(lowerLayer)); upperLink12.remove(); upper.remove(upperLink12); assertEquals (upper , np.getLinks(upperLayer)); upperMdLink12.remove(); upper.remove(upperMdLink12); assertEquals (upper , np.getLinks(upperLayer)); }