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
9 package org.opendaylight.protocol.pcep.impl;
11 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
12 import org.opendaylight.protocol.pcep.PCEPErrors;
15 * PCEP objects are identified with a couple <class, type>.
17 public class PCEPObjectIdentifier {
19 * Class identifier for {@link org.opendaylight.protocol.pcep.PCEPObject PCEPObject}
21 public static enum ObjectClass {
38 OBJCETIVE_FUNCTION(21),
39 GLOBAL_CONSTRAINTS(24),
40 UNREACHED_DESTINATION(28),
46 private final int identifier;
48 ObjectClass(final int identifier) {
49 this.identifier = identifier;
52 public int getIdentifier() {
53 return this.identifier;
56 public static ObjectClass getFromInt(int identifier) throws PCEPDocumentedException {
57 for (final ObjectClass type_e : ObjectClass.values()) {
58 if (type_e.getIdentifier() == identifier)
62 throw new PCEPDocumentedException("Unrecognized object class " + identifier, PCEPErrors.UNRECOGNIZED_OBJ_CLASS);
66 private final int objectType;
68 private final ObjectClass objectClass;
70 public PCEPObjectIdentifier(ObjectClass objectClass, int objectType) {
71 this.objectType = objectType;
72 this.objectClass = objectClass;
75 public int getObjectType() {
76 return this.objectType;
79 public ObjectClass getObjectClass() {
80 return this.objectClass;
84 public int hashCode() {
87 result = prime * result + ((this.objectClass == null) ? 0 : this.objectClass.hashCode());
88 result = prime * result + this.objectType;
93 public boolean equals(Object obj) {
98 if (this.getClass() != obj.getClass())
100 final PCEPObjectIdentifier other = (PCEPObjectIdentifier) obj;
101 if (this.objectClass != other.objectClass)
103 if (this.objectType != other.objectType)