Slice front-end request messages
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / messaging / BytesMessage.java
1 /*
2  * Copyright (c) 2017 Inocybe Technologies 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.controller.cluster.messaging;
9
10 import java.io.Serializable;
11 import java.util.Arrays;
12
13 /**
14  * Serializable message that stores a byte[].
15  *
16  * @author Thomas Pantelis
17  */
18 public class BytesMessage implements Serializable {
19     private static final long serialVersionUID = 1L;
20
21     private final byte[] bytes;
22
23     public BytesMessage(byte[] bytes) {
24         this.bytes = Arrays.copyOf(bytes, bytes.length);
25     }
26
27     @Override
28     public int hashCode() {
29         return Arrays.hashCode(bytes);
30     }
31
32     @Override
33     public boolean equals(Object obj) {
34         if (this == obj) {
35             return true;
36         }
37         if (obj == null) {
38             return false;
39         }
40         if (getClass() != obj.getClass()) {
41             return false;
42         }
43         BytesMessage other = (BytesMessage) obj;
44         return Arrays.equals(bytes, other.bytes);
45     }
46
47     @Override
48     public String toString() {
49         return "BytesMessage [bytes=" + Arrays.toString(bytes) + "]";
50     }
51 }