Remove deprecated LinkWeight interface

Change-Id: I4d3edab133d115ba189f317202d2dfba9b100918
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
index 3ad3c0e..3612273 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
@@ -24,6 +24,8 @@
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.Annotations;
 import org.onosproject.net.ChannelSpacing;
@@ -51,8 +53,7 @@
 import org.onosproject.net.resource.ResourceAllocation;
 import org.onosproject.net.resource.ResourceService;
 import org.onosproject.net.resource.Resources;
-import org.onosproject.net.topology.AdapterLinkWeigher;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
 import org.onosproject.net.topology.Topology;
 import org.onosproject.net.topology.TopologyEdge;
 import org.onosproject.net.topology.TopologyService;
@@ -337,34 +338,44 @@
         // Route in WDM topology
         Topology topology = topologyService.currentTopology();
         //TODO: refactor with LinkWeigher class Implementation
-        LinkWeight weight = new LinkWeight() {
+        LinkWeigher weight = new LinkWeigher() {
 
             @Override
-            public double weight(TopologyEdge edge) {
+            public Weight getInitialWeight() {
+                return ScalarWeight.toWeight(0.0);
+            }
+
+            @Override
+            public Weight getNonViableWeight() {
+                return ScalarWeight.NON_VIABLE_WEIGHT;
+            }
+
+            @Override
+            public Weight weight(TopologyEdge edge) {
                 // Disregard inactive or non-optical links
                 if (edge.link().state() == Link.State.INACTIVE) {
-                    return -1;
+                    return ScalarWeight.toWeight(-1);
                 }
                 if (edge.link().type() != Link.Type.OPTICAL) {
-                    return -1;
+                    return ScalarWeight.toWeight(-1);
                 }
                 // Adhere to static port mappings
                 DeviceId srcDeviceId = edge.link().src().deviceId();
                 if (srcDeviceId.equals(intent.getSrc().deviceId())) {
                     ConnectPoint srcStaticPort = staticPort(intent.getSrc());
                     if (srcStaticPort != null) {
-                        return srcStaticPort.equals(edge.link().src()) ? 1 : -1;
+                        return ScalarWeight.toWeight(srcStaticPort.equals(edge.link().src()) ? 1 : -1);
                     }
                 }
                 DeviceId dstDeviceId = edge.link().dst().deviceId();
                 if (dstDeviceId.equals(intent.getDst().deviceId())) {
                     ConnectPoint dstStaticPort = staticPort(intent.getDst());
                     if (dstStaticPort != null) {
-                        return dstStaticPort.equals(edge.link().dst()) ? 1 : -1;
+                        return ScalarWeight.toWeight(dstStaticPort.equals(edge.link().dst()) ? 1 : -1);
                     }
                 }
 
-                return 1;
+                return ScalarWeight.toWeight(1);
             }
         };
 
@@ -393,7 +404,7 @@
         Stream<Path> paths = topologyService.getKShortestPaths(topology,
                 start.deviceId(),
                 end.deviceId(),
-                AdapterLinkWeigher.adapt(weight))
+                weight)
                 .filter(p -> p.links().get(0).src().port().equals(start.port()) &&
                         p.links().get(p.links().size() - 1).dst().port().equals(end.port()));
         if (log.isDebugEnabled()) {
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
index 4b386bd..e45bfb1 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompiler.java
@@ -21,6 +21,8 @@
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
 import org.onosproject.net.ConnectPoint;
@@ -54,8 +56,9 @@
 import org.onosproject.net.resource.ResourceService;
 import org.onosproject.net.resource.ResourceAllocation;
 import org.onosproject.net.resource.Resources;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
 import org.onosproject.net.topology.Topology;
+import org.onosproject.net.topology.TopologyEdge;
 import org.onosproject.net.topology.TopologyService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -256,25 +259,41 @@
         // Route in OTU topology
         Topology topology = topologyService.currentTopology();
 
-        LinkWeight weight = edge -> {
-            // Disregard inactive or non-optical links
-            if (edge.link().state() == Link.State.INACTIVE) {
-                return -1;
+
+        class Weigher implements LinkWeigher {
+            @Override
+            public Weight weight(TopologyEdge edge) {
+                if (edge.link().state() == Link.State.INACTIVE) {
+                    return ScalarWeight.toWeight(-1);
+                }
+                if (edge.link().type() != Link.Type.OPTICAL) {
+                    return ScalarWeight.toWeight(-1);
+                }
+                // Find path with available TributarySlots resources
+                if (!isAvailableTributarySlots(intent, edge.link())) {
+                    return ScalarWeight.toWeight(-1);
+                }
+                return ScalarWeight.toWeight(1);
             }
-            if (edge.link().type() != Link.Type.OPTICAL) {
-                return -1;
+
+            @Override
+            public Weight getInitialWeight() {
+                return null;
             }
-            // Find path with available TributarySlots resources
-            if (!isAvailableTributarySlots(intent, edge.link())) {
-                return -1;
+
+            @Override
+            public Weight getNonViableWeight() {
+                return null;
             }
-            return 1;
-        };
+        }
+
+
+        LinkWeigher weigher = new Weigher();
 
         ConnectPoint start = intent.getSrc();
         ConnectPoint end = intent.getDst();
 
-        return topologyService.getPaths(topology, start.deviceId(), end.deviceId(), weight);
+        return topologyService.getPaths(topology, start.deviceId(), end.deviceId(), weigher);
     }
 
     private boolean isAvailableTributarySlots(OpticalOduIntent intent, Link link) {
diff --git a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java
index 46c408f..2c39274 100644
--- a/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java
+++ b/apps/optical-model/src/test/java/org/onosproject/net/optical/intent/impl/compiler/OpticalOduIntentCompilerTest.java
@@ -66,7 +66,7 @@
 import org.onosproject.net.optical.impl.DefaultOtuPort;
 import org.onosproject.net.provider.ProviderId;
 import org.onosproject.net.resource.MockResourceService;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
 import org.onosproject.net.topology.Topology;
 import org.onosproject.net.topology.TopologyServiceAdapter;
 
@@ -173,13 +173,13 @@
         Set<Path> paths = Sets.newHashSet(path);
 
         @Override
-        public Topology currentTopology() {
-            return null;
+        public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeigher weight) {
+            return paths;
         }
 
         @Override
-        public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
-            return paths;
+        public Topology currentTopology() {
+            return null;
         }
     }
 
diff --git a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java
index 7da14a9..b1f9d44 100644
--- a/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java
+++ b/apps/pathpainter/src/main/java/org/onosproject/pathpainter/PathPainterTopovMessageHandler.java
@@ -28,7 +28,7 @@
 import org.onosproject.net.Path;
 import org.onosproject.net.device.DeviceService;
 import org.onosproject.net.topology.GeoDistanceLinkWeight;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
 import org.onosproject.net.topology.PathService;
 import org.onosproject.net.topology.TopologyEvent;
 import org.onosproject.net.topology.TopologyListener;
@@ -78,7 +78,7 @@
 
     private Set<Link> allPathLinks;
     private boolean listenersRemoved;
-    private LinkWeight linkData;
+    private LinkWeigher linkData;
     private int highlightDelay;
 
     private enum Mode {
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
index 3ecdd5b..e7ef935 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
@@ -18,6 +18,7 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
 import org.onosproject.net.DisjointPath;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -68,6 +69,7 @@
 import org.onosproject.net.link.LinkEvent;
 import org.onosproject.net.MastershipRole;
 import org.onosproject.bandwidthmgr.api.BandwidthMgmtService;
+import org.onosproject.net.topology.LinkWeigher;
 import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
 import org.onosproject.pce.pceservice.constraint.CapabilityConstraint.CapabilityType;
 import org.onosproject.pce.pceservice.constraint.CostConstraint;
@@ -75,7 +77,6 @@
 import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint;
 import org.onosproject.net.resource.Resource;
 import org.onosproject.net.resource.ResourceAllocation;
-import org.onosproject.net.topology.LinkWeight;
 import org.onosproject.net.topology.PathService;
 import org.onosproject.net.topology.TopologyEdge;
 import org.onosproject.net.topology.TopologyEvent;
@@ -225,7 +226,7 @@
      * @param constraints path constraints
      * @return edge-weight function
      */
-    private LinkWeight weight(List<Constraint> constraints) {
+    private LinkWeigher weight(List<Constraint> constraints) {
         return new TeConstraintBasedLinkWeight(constraints);
     }
 
@@ -957,7 +958,7 @@
         return value;
     }
 
-    protected class TeConstraintBasedLinkWeight implements LinkWeight {
+    protected class TeConstraintBasedLinkWeight implements LinkWeigher {
 
         private final List<Constraint> constraints;
 
@@ -976,10 +977,20 @@
         }
 
         @Override
-        public double weight(TopologyEdge edge) {
+        public Weight getInitialWeight() {
+            return ScalarWeight.toWeight(0.0);
+        }
+
+        @Override
+        public Weight getNonViableWeight() {
+            return ScalarWeight.toWeight(0.0);
+        }
+
+        @Override
+        public Weight weight(TopologyEdge edge) {
             if (!constraints.iterator().hasNext()) {
                 //Takes default cost/hopcount as 1 if no constraints specified
-                return 1.0;
+                return ScalarWeight.toWeight(1.0);
             }
 
             Iterator<Constraint> it = constraints.iterator();
@@ -1003,7 +1014,7 @@
                     cost = constraint.cost(edge.link(), null);
                 }
             }
-            return cost;
+            return ScalarWeight.toWeight(cost);
         }
     }
 
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
index bdd593c..fd13454 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
@@ -29,6 +29,8 @@
 import org.onlab.graph.DijkstraGraphSearch;
 import org.onlab.graph.Graph;
 import org.onlab.graph.GraphPathSearch;
+import org.onlab.graph.ScalarWeight;
+import org.onlab.graph.Weight;
 import org.onlab.packet.ChassisId;
 import org.onlab.util.Bandwidth;
 import org.onosproject.net.AnnotationKeys;
@@ -53,7 +55,7 @@
 import org.onosproject.net.provider.ProviderId;
 import org.onosproject.net.topology.DefaultTopologyEdge;
 import org.onosproject.net.topology.DefaultTopologyVertex;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
 import org.onosproject.net.topology.TopologyEdge;
 import org.onosproject.net.topology.TopologyVertex;
 import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
@@ -82,7 +84,6 @@
 import static org.onosproject.net.DeviceId.deviceId;
 import static org.onosproject.net.Link.State.ACTIVE;
 import static org.onosproject.net.Link.Type.DIRECT;
-import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
 import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.COST;
 import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.TE_COST;
 
@@ -168,7 +169,7 @@
      * @param constraints path constraints
      * @return edge-weight function
      */
-    private LinkWeight weight(List<Constraint> constraints) {
+    private LinkWeigher weight(List<Constraint> constraints) {
         return new MockTeConstraintBasedLinkWeight(constraints);
     }
 
@@ -180,7 +181,7 @@
                    new DefaultTopologyEdge(D3, D4, link4)));
 
         GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
-                graphSearch().search(graph, D1, D4, adapt(weight(constraints)), ALL_PATHS);
+                graphSearch().search(graph, D1, D4, weight(constraints), ALL_PATHS);
         ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
         for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
             builder.add(networkPath(path));
@@ -211,7 +212,7 @@
         }
     }
 
-    private class MockTeConstraintBasedLinkWeight implements LinkWeight {
+    private class MockTeConstraintBasedLinkWeight implements LinkWeigher {
 
         private final List<Constraint> constraints;
 
@@ -230,10 +231,20 @@
         }
 
         @Override
-        public double weight(TopologyEdge edge) {
+        public Weight getInitialWeight() {
+            return ScalarWeight.toWeight(0.0);
+        }
+
+        @Override
+        public Weight getNonViableWeight() {
+            return ScalarWeight.NON_VIABLE_WEIGHT;
+        }
+
+        @Override
+        public Weight weight(TopologyEdge edge) {
             if (!constraints.iterator().hasNext()) {
                 //Takes default cost/hopcount as 1 if no constraints specified
-                return 1.0;
+                return ScalarWeight.toWeight(1.0);
             }
 
             Iterator<Constraint> it = constraints.iterator();
@@ -259,7 +270,7 @@
                     cost = constraint.cost(edge.link(), null);
                 }
             }
-            return cost;
+            return ScalarWeight.toWeight(cost);
         }
     }
 
@@ -1274,7 +1285,7 @@
                    new DefaultTopologyEdge(D4, D5, link5)));
 
         GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
-                graphSearch().search(graph, D1, D5, adapt(weight(constraints)), ALL_PATHS);
+                graphSearch().search(graph, D1, D5, weight(constraints), ALL_PATHS);
         ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
         for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
             builder.add(networkPath(path));
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
index 432ffb6..9cf7069 100644
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
+++ b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
@@ -56,7 +56,7 @@
 import org.onosproject.net.provider.ProviderId;
 import org.onosproject.net.topology.DefaultTopologyEdge;
 import org.onosproject.net.topology.DefaultTopologyVertex;
-import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.LinkWeigher;
 import org.onosproject.net.topology.PathServiceAdapter;
 import org.onosproject.net.topology.Topology;
 import org.onosproject.net.topology.TopologyEdge;
@@ -92,7 +92,6 @@
 import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
 import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
 import static org.onosproject.net.MastershipRole.MASTER;
-import static org.onosproject.net.topology.AdapterLinkWeigher.adapt;
 import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING;
 import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
 import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING;
@@ -1476,7 +1475,7 @@
         }
 
         @Override
-        public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
+        public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeigher weight) {
             DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
             DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
             Set<TopologyVertex> vertices = graph.getVertexes();
@@ -1486,7 +1485,7 @@
             }
 
             GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = PathComputationTest.graphSearch()
-                    .search(graph, srcV, dstV, adapt(weight), ALL_PATHS);
+                    .search(graph, srcV, dstV, weight, ALL_PATHS);
             ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
             for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
                 builder.add(PathComputationTest.networkPath(path));
@@ -1521,7 +1520,7 @@
     private class MockPathService extends PathServiceAdapter {
         Set<Path> computedPaths;
         @Override
-        public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeight weight) {
+        public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weight) {
             // If either edge is null, bail with no paths.
             if (src == null || dst == null) {
                 return ImmutableSet.of();