00a40be545212fb3e06464b68dc3e1af0b6fc302
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / subobject / EROPathKey128SubobjectParser.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.pcep.impl.subobject;
9
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.protocol.pcep.spi.AbstractEROPathKeySubobjectParser;
12 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
13 import org.opendaylight.protocol.util.ByteArray;
14
15 public final class EROPathKey128SubobjectParser extends AbstractEROPathKeySubobjectParser {
16
17     @Override
18     protected byte[] readPceId(final ByteBuf buffer) {
19         return ByteArray.readBytes(buffer, PCE128_ID_F_LENGTH);
20     }
21
22     @Override
23     protected void checkContentLenght(final int lenght) throws PCEPDeserializerException {
24         if (lenght != CONTENT128_LENGTH) {
25             throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + lenght + "; Expected: >"
26                 + CONTENT128_LENGTH + ".");
27         }
28     }
29 }