Remove hand-written ServiceLoader services
[bgpcep.git] / pcep / segment-routing / src / main / java / org / opendaylight / protocol / pcep / segment / routing / PCEPSegmentRoutingCapability.java
index a749a51d949076f407f7b8dfc56f9fbd8b41ac9e..5fc7351f2e03450bdc1203c6f6ca2e263faaa99d 100644 (file)
@@ -7,37 +7,55 @@
  */
 package org.opendaylight.protocol.pcep.segment.routing;
 
+import com.google.common.base.MoreObjects;
 import java.net.InetSocketAddress;
+import org.eclipse.jdt.annotation.NonNull;
+import org.kohsuke.MetaInfServices;
 import org.opendaylight.protocol.pcep.PCEPCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapabilityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
 import org.opendaylight.yangtools.yang.common.Uint8;
 
+@MetaInfServices
 public class PCEPSegmentRoutingCapability implements PCEPCapability {
+    private static final @NonNull Tlvs1 AUGMENTATION = new Tlvs1Builder()
+        .setSrPceCapability(new SrPceCapabilityBuilder()
+            .setNFlag(Boolean.FALSE)
+            .setXFlag(Boolean.FALSE)
+            .setMsd(Uint8.ZERO)
+            .build())
+        .build();
 
     private final boolean isSegmentRoutingCapable;
 
+    public PCEPSegmentRoutingCapability() {
+        this(true);
+    }
+
     public PCEPSegmentRoutingCapability(final boolean isSegmentRoutingCapable) {
         this.isSegmentRoutingCapable = isSegmentRoutingCapable;
     }
 
     @Override
     public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) {
-        if (this.isSegmentRoutingCapable) {
-            builder.addAugmentation(new Tlvs1Builder()
-                .setSrPceCapability(new SrPceCapabilityBuilder().setNFlag(Boolean.FALSE).setXFlag(Boolean.FALSE)
-                    .setMsd(Uint8.ZERO).build())
-                .build());
+        if (isSegmentRoutingCapable) {
+            builder.addAugmentation(AUGMENTATION);
         }
     }
 
     public boolean isSegmentRoutingCapable() {
-        return this.isSegmentRoutingCapable;
+        return isSegmentRoutingCapable;
     }
 
     @Override
     public boolean isStateful() {
         return false;
     }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this).add("srCapable", isSegmentRoutingCapable).toString();
+    }
 }