View Javadoc

1   package com.atlassian.vcache.internal.core.cas;
2   
3   import java.util.Arrays;
4   
5   import static java.util.Objects.requireNonNull;
6   
7   /**
8    * Implementation of {@link IdentifiedData} that holds an array of bytes.
9    *
10   * @since 1.1.0
11   */
12  public class IdentifiedDataBytes extends IdentifiedData {
13      private final byte[] bytes;
14  
15      public IdentifiedDataBytes(byte[] bytes) {
16          this.bytes = requireNonNull(bytes);
17      }
18  
19      public byte[] getBytes() {
20          return bytes;
21      }
22  
23      @Override
24      public boolean equals(Object o) {
25          if (this == o) {
26              return true;
27          }
28          if (!(o instanceof IdentifiedDataBytes)) {
29              return false;
30          }
31          if (!super.equals(o)) {
32              return false;
33          }
34  
35          final IdentifiedDataBytes that = (IdentifiedDataBytes) o;
36  
37          return Arrays.equals(bytes, that.bytes);
38      }
39  
40      @Override
41      public int hashCode() {
42          return Arrays.hashCode(bytes);
43      }
44  }