BUG-47: more subobject models
[bgpcep.git] / pcep / api / src / main / java / org / opendaylight / protocol / pcep / subobject / RROAttributesSubobject.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 package org.opendaylight.protocol.pcep.subobject;
9
10 import java.util.Arrays;
11
12 public class RROAttributesSubobject extends ReportedRouteSubobject {
13
14     private final byte[] attributes;
15
16     public RROAttributesSubobject(byte[] attributes) {
17         super();
18
19         if (attributes.length % 4 != 0)
20             throw new IllegalArgumentException("Attributes have to be multiple of 4.");
21
22         this.attributes = attributes;
23     }
24
25     public byte[] getAttributes() {
26         return this.attributes;
27     }
28
29     @Override
30     public int hashCode() {
31         final int prime = 31;
32         int result = 1;
33         result = prime * result + Arrays.hashCode(this.attributes);
34         return result;
35     }
36
37     @Override
38     public boolean equals(Object obj) {
39         if (this == obj)
40             return true;
41         if (obj == null)
42             return false;
43         if (this.getClass() != obj.getClass())
44             return false;
45         final RROAttributesSubobject other = (RROAttributesSubobject) obj;
46         if (!Arrays.equals(this.attributes, other.attributes))
47             return false;
48         return true;
49     }
50
51     @Override
52     public String toString() {
53         final StringBuilder builder = new StringBuilder();
54         builder.append("RROAttributesSubobject [attributes=");
55         builder.append(Arrays.toString(this.attributes));
56         builder.append("]");
57         return builder.toString();
58     }
59
60 }