2 * Copyright (c) 2014 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
9 package org.opendaylight.protocol.pcep.impl;
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.protocol.pcep.parser.tlv.AbstractVendorInformationTlvParser;
13 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.EnterpriseSpecificInformation;
16 import org.opendaylight.yangtools.yang.binding.DataContainer;
18 public class TestVendorInformationTlvParser extends AbstractVendorInformationTlvParser {
20 private static final EnterpriseNumber TEST_ENTERPRISE_NUMBER = new EnterpriseNumber(0L);
23 public void serializeEnterpriseSpecificInformation(final EnterpriseSpecificInformation enterpriseSpecificInformation,
24 final ByteBuf buffer) {
25 if (enterpriseSpecificInformation instanceof TestEnterpriseSpecificInformation) {
26 buffer.writeInt(((TestEnterpriseSpecificInformation) enterpriseSpecificInformation).getValue());
31 public EnterpriseSpecificInformation parseEnterpriseSpecificInformation(final ByteBuf buffer)
32 throws PCEPDeserializerException {
33 return new TestEnterpriseSpecificInformation(buffer.readInt());
37 public EnterpriseNumber getEnterpriseNumber() {
38 return TEST_ENTERPRISE_NUMBER;
41 protected static final class TestEnterpriseSpecificInformation implements EnterpriseSpecificInformation {
43 private final int value;
45 public TestEnterpriseSpecificInformation(final int value) {
49 public int getValue() {
54 public Class<? extends DataContainer> getImplementedInterface() {
55 return TestEnterpriseSpecificInformation.class;
59 public int hashCode() {
62 result = prime * result + this.value;
67 public boolean equals(final Object obj) {
74 if (getClass() != obj.getClass()) {
77 TestEnterpriseSpecificInformation other = (TestEnterpriseSpecificInformation) obj;
78 if (this.value != other.value) {