BUG-64 : initial rewrite, XROSubobjectRegistry.
[bgpcep.git] / pcep / ietf-stateful02 / src / main / java / org / opendaylight / protocol / pcep / crabbe / initiated00 / LSPCleanupTlvParser.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.crabbe.initiated00;
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.protocol.util.ByteArray;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.lsp.cleanup.tlv.LspCleanup;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.lsp.cleanup.tlv.LspCleanupBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
17
18 public final class LSPCleanupTlvParser implements TlvParser, TlvSerializer {
19
20         public static final int TYPE = 26;
21
22         @Override
23         public byte[] serializeTlv(final Tlv tlv) {
24                 return ByteArray.intToBytes(((LspCleanup) tlv).getTimeout().intValue());
25         }
26
27         @Override
28         public Tlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
29                 return new LspCleanupBuilder().setTimeout(ByteArray.bytesToLong(buffer)).build();
30         }
31
32         @Override
33         public int getType() {
34                 return TYPE;
35         }
36 }