Demand extends NetworkElement implements IMonitorizableElement { public void remove() { checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); if (this.coupledUpperOrSameLayerLink != null) this.decouple(); if (bidirectionalPair != null) { this.bidirectionalPair.bidirectionalPair = null; this.bidirectionalPair = null; } if (routingType == RoutingType.SOURCE_ROUTING) for (Route route : new TreeSet<Route> (cache_routes)) route.remove(); else { for (Link e : this.cacheHbH_frs.keySet()) e.cacheHbH_frs.remove(this); for (Link e : this.cacheHbH_normCarriedOccupiedPerLinkCurrentState.keySet()) { final double x_deOccup = this.cacheHbH_normCarriedOccupiedPerLinkCurrentState.get(e).getSecond(); e.cacheHbH_normCarriedOccupiedPerTraversingDemandCurrentState.remove(this); e.cache_totalCarriedTraffic -= x_deOccup; e.cache_totalOccupiedCapacity -= x_deOccup; } } layer.cache_nodePairDemandsThisLayer.get(Pair.of(ingressNode, egressNode)).remove(this); if (layer.cache_nodePairDemandsThisLayer.get(Pair.of(ingressNode, egressNode)).isEmpty()) layer.cache_nodePairDemandsThisLayer.remove(Pair.of(ingressNode, egressNode)); for (String tag : tags) netPlan.cache_taggedElements.get(tag).remove(this); netPlan.cache_id2DemandMap.remove(id); NetPlan.removeNetworkElementAndShiftIndexes (layer.demands , index); ingressNode.cache_nodeOutgoingDemands.remove (this); egressNode.cache_nodeIncomingDemands.remove (this); final Pair<SortedSet<Demand>,SortedSet<MulticastDemand>> qosInfo = layer.cache_qosTypes2DemandMap.get(qosType); assert qosInfo != null; final boolean removed = qosInfo.getFirst().remove(this); assert removed; if (qosInfo.getFirst().isEmpty() && qosInfo.getSecond().isEmpty()) layer.cache_qosTypes2DemandMap.remove(qosType); final NetPlan npOld = this.netPlan; removeId(); if (ErrorHandling.isDebugEnabled()) npOld.checkCachesConsistency(); } Demand(NetPlan netPlan , long id , int index , NetworkLayer layer , Node ingressNode , Node egressNode , double offeredTraffic , RoutingType routingType , AttributeMap attributes); SortedSet<Node> getEndNodes(); void setOfferedTrafficPerPeriodGrowthFactor(double growthFactor); double getOfferedTrafficPerPeriodGrowthFactor(); void setQoSType(String newQosType); String getQosType(); void setMaximumAcceptableE2EWorstCaseLatencyInMs(double maxLatencyMs); double getMaximumAcceptableE2EWorstCaseLatencyInMs(); boolean isSourceRouting(); void checkRoutingType(RoutingType routingType); IntendedRecoveryType getIntendedRecoveryType(); void setIntendedRecoveryType(IntendedRecoveryType recoveryType); SortedSet<Route> getRoutes(); void setRoutingType(RoutingType newRoutingType); SortedSet<Route> getRoutesAreBackup(); SortedSet<Route> getRoutesHaveBackup(); SortedSet<Route> getRoutesHaveNoBackup(); SortedSet<Route> getRoutesAreNotBackup(); double getWorstCaseLengthInKm(); double getWorstCasePropagationTimeInMs(); boolean isTraversingOversubscribedLinks(); boolean isTraversingOversubscribedResources(); List<String> getServiceChainSequenceOfTraversedResourceTypes(); void setServiceChainSequenceOfTraversedResourceTypes(List<String> resourceTypesSequence); NetworkLayer getLayer(); boolean isBifurcated(); boolean isBlocked(); boolean isServiceChainRequest(); boolean isCoupled(); boolean isCoupledInSameLayer(); boolean isCoupledInDifferentLayer(); double getOfferedTraffic(); SortedMap<Pair<Demand,Link>,Double> getForwardingRules(); double getCarriedTraffic(); double getBlockedTraffic(); RoutingType getRoutingType(); RoutingCycleType getRoutingCycleType(); Node getIngressNode(); Node getEgressNode(); Demand getBidirectionalPair(); void setBidirectionalPair(Demand d); boolean isBidirectional(); Demand createBidirectionalPair(); Link getCoupledLink(); void coupleToUpperOrSameLayerLink(Link link); Link coupleToNewLinkCreated(NetworkLayer newLinkLayer); void decouple(); void removeAllForwardingRules(); void removeAllRoutes(); Pair<SortedSet<Route>,Double> computeShortestPathRoutes(double [] costs); Pair<SortedSet<Route>,Double> computeMinimumCostServiceChains(double [] linkCosts , double [] resourceCosts); void remove(); void setOfferedTraffic(double offeredTraffic); @Override String toString(); SortedSet<Link> getLinksWithNonZeroForwardingRules(); Pair<SortedSet<Link>,SortedSet<Link>> getLinksNoDownPropagationPotentiallyCarryingTraffic(); SortedMap<Link, Double> getTraversedLinksAndCarriedTraffic(final boolean normalizedToOfferedTraffic); double getOccupiedCapacity(Link e); TrafficSeries getMonitoredOrForecastedOfferedTraffic(); void setMonitoredOrForecastedOfferedTraffic(TrafficSeries newTimeSeries); @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() { d12.remove(); scd123.remove(); }