BUG-47: more subobject models
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / subobject / RROPathKeyWith128PCEIDSubobject.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
9 package org.opendaylight.protocol.pcep.subobject;
10
11 import java.util.Arrays;
12
13 public class RROPathKeyWith128PCEIDSubobject extends ReportedRouteSubobject {
14
15     private final int pathKey;
16
17     private final byte[] pceId;
18
19     public RROPathKeyWith128PCEIDSubobject(int pathKey, byte[] pceId) {
20         super();
21         this.pathKey = pathKey;
22         if (pceId == null)
23             throw new IllegalArgumentException("PCE ID can't be null.");
24
25         if (pceId.length != 16)
26             throw new IllegalArgumentException("PCE ID is not 16 bytes long.");
27
28         this.pceId = pceId;
29     }
30
31     public int getPathKey() {
32         return this.pathKey;
33     }
34
35     public byte[] getPceId() {
36         return this.pceId;
37     }
38
39     @Override
40     public int hashCode() {
41         final int prime = 31;
42         int result = 1;
43         result = prime * result + this.pathKey;
44         result = prime * result + Arrays.hashCode(this.pceId);
45         return result;
46     }
47
48     @Override
49     public boolean equals(Object obj) {
50         if (this == obj)
51             return true;
52         if (obj == null)
53             return false;
54         if (this.getClass() != obj.getClass())
55             return false;
56         final RROPathKeyWith128PCEIDSubobject other = (RROPathKeyWith128PCEIDSubobject) obj;
57         if (this.pathKey != other.pathKey)
58             return false;
59         if (!Arrays.equals(this.pceId, other.pceId))
60             return false;
61         return true;
62     }
63
64     @Override
65     public String toString() {
66         final StringBuilder builder = new StringBuilder();
67         builder.append("RROPathKeyWith128PCEIDSubobject [pathKey=");
68         builder.append(this.pathKey);
69         builder.append(", pceId=");
70         builder.append(Arrays.toString(this.pceId));
71         builder.append("]");
72         return builder.toString();
73     }
74
75 }