Update ObjectParser API
[bgpcep.git] / pcep / base-parser / src / main / java / org / opendaylight / protocol / pcep / parser / object / PCEPMetricObjectParser.java
index 58db1b40ad10dd1354036f0c62916d7fefd17fd3..7ec961866701523f846cf8de110e6ce59328d528 100644 (file)
@@ -13,7 +13,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -28,11 +28,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link Metric}
  */
-public class PCEPMetricObjectParser implements ObjectParser, ObjectSerializer {
+public final class PCEPMetricObjectParser extends CommonObjectParser implements ObjectSerializer {
 
-    public static final int CLASS = 6;
-
-    public static final int TYPE = 1;
+    private static final int CLASS = 6;
+    private static final int TYPE = 1;
 
     /*
      * lengths of fields in bytes
@@ -53,6 +52,10 @@ public class PCEPMetricObjectParser implements ObjectParser, ObjectSerializer {
 
     private static final int SIZE = METRIC_VALUE_F_LENGTH + METRIC_VALUE_F_LENGTH;
 
+    public PCEPMetricObjectParser() {
+        super(CLASS, TYPE);
+    }
+
     @Override
     public Metric parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
         Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");