2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.pcep.impl.object;
10 import java.util.Arrays;
12 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
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.bandwidth.object.Bandwidth;
18 * Parser for {@link Bandwidth}
20 public class PCEPExistingBandwidthObjectParser extends AbstractBandwidthParser {
22 public static final int CLASS = 5;
24 public static final int TYPE = 2;
26 private static final int BANDWIDTH_LENGTH = 4;
28 public PCEPExistingBandwidthObjectParser(final TlvHandlerRegistry tlvReg) {
33 public byte[] serializeObject(final Object object) {
34 if (!(object instanceof Bandwidth)) {
35 throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed BandwidthObject.");
37 final byte[] retBytes = Arrays.copyOf(((Bandwidth) object).getBandwidth().getValue(), BANDWIDTH_LENGTH);
38 return ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), retBytes);
42 public int getObjectType() {
47 public int getObjectClass() {