- private static org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing
- .or.general.co.routing.CoRouting updateCoCoRouting(org.opendaylight.yang.gen.v1.http.org.openroadm.routing
- .constrains.rev161014.constraints.co.routing.or.general.co.routing.CoRouting hard, org.opendaylight
- .yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.co
- .routing.CoRouting soft) {
- org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general
- .co.routing.CoRoutingBuilder result = new org.opendaylight.yang.gen.v1.http.org.openroadm.routing
- .constrains.rev161014.constraints.co.routing.or.general.co.routing.CoRoutingBuilder(soft);
- if (hard != null) {
- result.getExistingService().addAll(hard.getExistingService());
- }
- return result.build();
+ private static Distance updateDistance(Distance hard, Distance soft) {
+ return soft == null || hard.getMaxDistance().longValue() <= soft.getMaxDistance().longValue()
+ ? new DistanceBuilder(hard).build()
+ : new DistanceBuilder(soft).build();
+ }
+
+ private static HopCount updateHopCount(HopCount hard, HopCount soft) {
+ if (soft == null) {
+ return new HopCountBuilder(hard).build();
+ }
+ HopCountBuilder hcBldr = new HopCountBuilder();
+ if (soft.getMaxWdmHopCount() == null) {
+ if (hard.getMaxWdmHopCount() != null) {
+ hcBldr.setMaxWdmHopCount(hard.getMaxWdmHopCount());
+ }
+ } else {
+ hcBldr.setMaxWdmHopCount(
+ hard.getMaxWdmHopCount() == null
+ || soft.getMaxWdmHopCount().intValue() <= hard.getMaxWdmHopCount().intValue()
+ ? soft.getMaxWdmHopCount()
+ : hard.getMaxWdmHopCount());
+ }
+ if (soft.getMaxOtnHopCount() == null) {
+ if (hard.getMaxOtnHopCount() != null) {
+ hcBldr.setMaxOtnHopCount(hard.getMaxOtnHopCount());
+ }
+ } else {
+ hcBldr.setMaxOtnHopCount(
+ hard.getMaxOtnHopCount() == null
+ || soft.getMaxOtnHopCount().intValue() <= hard.getMaxOtnHopCount().intValue()
+ ? soft.getMaxOtnHopCount()
+ : hard.getMaxOtnHopCount());
+ }
+ return hcBldr.build();
+ }
+
+ private static TEMetric updateTEMetric(TEMetric hard, TEMetric soft) {
+ if (soft == null) {
+ return new TEMetricBuilder(hard).build();
+ }
+ TEMetricBuilder temBldr = new TEMetricBuilder();
+ if (soft.getMaxWdmTEMetric() == null) {
+ if (hard.getMaxWdmTEMetric() != null) {
+ temBldr.setMaxWdmTEMetric(hard.getMaxWdmTEMetric());
+ }
+ } else {
+ temBldr.setMaxWdmTEMetric(
+ hard.getMaxWdmTEMetric() == null
+ || soft.getMaxWdmTEMetric().intValue() <= hard.getMaxWdmTEMetric().intValue()
+ ? soft.getMaxWdmTEMetric()
+ : hard.getMaxWdmTEMetric());
+ }
+ if (soft.getMaxOtnTEMetric() == null) {
+ if (hard.getMaxOtnTEMetric() != null) {
+ temBldr.setMaxOtnTEMetric(hard.getMaxWdmTEMetric());
+ }
+ } else {
+ temBldr.setMaxOtnTEMetric(
+ hard.getMaxOtnTEMetric() == null
+ || soft.getMaxOtnTEMetric().intValue() <= hard.getMaxOtnTEMetric().intValue()
+ ? soft.getMaxOtnTEMetric()
+ : hard.getMaxOtnTEMetric());
+ }
+ return temBldr.build();
+ }
+
+ private static CoRouting updateCoRouting(CoRouting hard, CoRouting soft) {
+ CoRoutingBuilder coRoutingBldr = soft == null ? new CoRoutingBuilder() : new CoRoutingBuilder(soft);
+
+ Map<
+ ServiceIdentifierListKey,
+ ServiceIdentifierList> serviceIdentifierList = coRoutingBldr.getServiceIdentifierList() == null
+ ? new HashMap<>()
+ : new HashMap<>(coRoutingBldr.getServiceIdentifierList());
+ if (!hard.getServiceIdentifierList().isEmpty()) {
+ serviceIdentifierList.putAll(hard.getServiceIdentifierList());
+ coRoutingBldr.setServiceIdentifierList(serviceIdentifierList);
+ }
+ return coRoutingBldr.build();