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.object;
10 import org.opendaylight.protocol.pcep.PCEPObject;
11 import com.google.common.base.Objects.ToStringHelper;
14 * Structure of ClassType Object.
16 * @see <a href="http://tools.ietf.org/html/rfc5455#section-5"> Object
19 public class PCEPClassTypeObject extends PCEPObject {
21 private final short classType;
24 * Constructs ClassType Object with given class type.
27 * short, must be positive and less than 8.
29 public PCEPClassTypeObject(short classType) {
31 if (classType < 0 || classType > 7) {
32 throw new IllegalArgumentException("ClassType range overstepped.");
34 this.classType = classType;
42 public short getClassType() {
43 return this.classType;
47 public int hashCode() {
49 int result = super.hashCode();
50 result = prime * result + this.classType;
55 public boolean equals(Object obj) {
58 if (!super.equals(obj))
60 if (!(obj instanceof PCEPClassTypeObject))
62 final PCEPClassTypeObject other = (PCEPClassTypeObject) obj;
63 if (this.classType != other.classType)
69 protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
70 toStringHelper.add("classType", this.classType);
71 return super.addToStringAttributes(toStringHelper);