Rework PCEPDeserializerException and move it into SPI
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / object / PCEPSvecObjectParser.java
index d7f45f39e03419566c8b6d153fc7e2fa7b417f3f..666af449dfb47a28fd5dfa6134dd8dd1445dd97f 100644 (file)
@@ -10,21 +10,20 @@ package org.opendaylight.protocol.pcep.impl.object;
 import java.util.BitSet;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SvecObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.SvecBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.Svec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.SvecBuilder;
 
 import com.google.common.collect.Lists;
 
 /**
- * Parser for {@link SvecObject}
+ * Parser for {@link Svec}
  */
 public class PCEPSvecObjectParser extends AbstractObjectWithTlvsParser<SvecBuilder> {
 
@@ -61,7 +60,7 @@ public class PCEPSvecObjectParser extends AbstractObjectWithTlvsParser<SvecBuild
        }
 
        @Override
-       public SvecObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
+       public Svec parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException {
                if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                }
@@ -97,11 +96,11 @@ public class PCEPSvecObjectParser extends AbstractObjectWithTlvsParser<SvecBuild
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof SvecObject)) {
+               if (!(object instanceof Svec)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed SvecObject.");
                }
 
-               final SvecObject svecObj = (SvecObject) object;
+               final Svec svecObj = (Svec) object;
                final byte[] retBytes = new byte[svecObj.getRequestsIds().size() * REQ_LIST_ITEM_LENGTH + REQ_ID_LIST_OFFSET];
                final List<RequestId> requestIDs = svecObj.getRequestsIds();
                final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);