2 * Copyright (c) 2017 Brocade Communications 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.controller.cluster.raft.persisted;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Arrays;
13 import org.eclipse.jdt.annotation.NonNull;
16 * Snapshot State implementation backed by a byte[].
18 * @author Thomas Pantelis
20 public final class ByteState implements Snapshot.State {
21 private static final long serialVersionUID = 1L;
23 private final byte @NonNull[] bytes;
25 private ByteState(final byte @NonNull[] bytes) {
26 this.bytes = requireNonNull(bytes);
29 public static @NonNull ByteState of(final byte @NonNull[] bytes) {
30 return new ByteState(bytes);
33 public static @NonNull ByteState empty() {
34 return new ByteState(new byte[0]);
37 public byte @NonNull[] getBytes() {
42 public int hashCode() {
45 result = prime * result + Arrays.hashCode(bytes);
50 public boolean equals(final Object obj) {
57 if (getClass() != obj.getClass()) {
60 ByteState other = (ByteState) obj;
61 if (!Arrays.equals(bytes, other.bytes)) {
68 public String toString() {
69 return "ByteState [bytes=" + Arrays.toString(bytes) + "]";