Bumped to ietf-stateful-02.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / stateful02 / NodeIdentifierTlvParser.java
1 /*
2  * Copyright (c) 2014 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.stateful02;
9
10 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
11 import org.opendaylight.protocol.pcep.spi.TlvParser;
12 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.NodeIdentifier;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.node.identifier.tlv.NodeIdentifierBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
16
17 public class NodeIdentifierTlvParser implements TlvParser, TlvSerializer {
18
19         public static final int TYPE = 24;
20
21         @Override
22         public int getType() {
23                 return TYPE;
24         }
25
26         @Override
27         public byte[] serializeTlv(final Tlv tlv) {
28                 return ((NodeIdentifier) tlv).getValue();
29         }
30
31         @Override
32         public Tlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
33                 return new NodeIdentifierBuilder().setNodeId(new NodeIdentifier(buffer)).build();
34         }
35 }