BUG-47 : switched subobjects to generated source code.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / object / PCEPPathKeyObjectParser.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.object;
9
10 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
11 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
12 import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
13 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.path.key.expansion.PathKeyBuilder;
19
20 /**
21  * Parser for {@link PathKeyObject}
22  */
23 public class PCEPPathKeyObjectParser extends AbstractObjectWithTlvsParser<PathKeyBuilder> {
24
25         public static final int CLASS = 16;
26
27         public static final int TYPE = 1;
28
29         public PCEPPathKeyObjectParser(final TlvHandlerRegistry tlvReg) {
30                 super(tlvReg);
31         }
32
33         @Override
34         public PathKeyObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
35         PCEPDocumentedException {
36                 // FIXME : finish
37
38                 final PathKeyBuilder builder = new PathKeyBuilder();
39
40                 builder.setIgnore(header.isIgnore());
41                 builder.setProcessingRule(header.isProcessingRule());
42
43                 return builder.build();
44         }
45
46         @Override
47         public void addTlv(final PathKeyBuilder builder, final Tlv tlv) {
48                 // No tlvs defined
49         }
50
51         @Override
52         public byte[] serializeObject(final Object object) {
53                 if (!(object instanceof PathKeyObject)) {
54                         throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed PathKeyObject.");
55                 }
56
57                 final PathKeyObject pkey = (PathKeyObject) object;
58
59                 // FIXME, but no Tlvs defined
60                 // final byte[] tlvs = PCEPTlvParser.put(lspaObj.getTlvs());
61                 // final byte[] retBytes = new byte[TLVS_F_OFFSET + tlvs.length];
62                 // ByteArray.copyWhole(tlvs, retBytes, TLVS_F_OFFSET);
63                 return new byte[0];
64         }
65
66         @Override
67         public int getObjectType() {
68                 return TYPE;
69         }
70
71         @Override
72         public int getObjectClass() {
73                 return CLASS;
74         }
75 }