1 // Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2 //  This source code is licensed under both the GPLv2 (found in the
3 //  COPYING file in the root directory) and Apache 2.0 License
4 //  (found in the LICENSE.Apache file in the root directory).
5 
6 package org.rocksdb;
7 
8 import java.nio.file.Path;
9 
10 /**
11  * Tuple of database path and target size
12  */
13 public class DbPath {
14   final Path path;
15   final long targetSize;
16 
DbPath(final Path path, final long targetSize)17   public DbPath(final Path path, final long targetSize) {
18     this.path = path;
19     this.targetSize = targetSize;
20   }
21 
22   @Override
equals(final Object o)23   public boolean equals(final Object o) {
24     if (this == o) {
25       return true;
26     }
27 
28     if (o == null || getClass() != o.getClass()) {
29       return false;
30     }
31 
32     final DbPath dbPath = (DbPath) o;
33 
34     if (targetSize != dbPath.targetSize) {
35       return false;
36     }
37 
38     return path != null ? path.equals(dbPath.path) : dbPath.path == null;
39   }
40 
41   @Override
hashCode()42   public int hashCode() {
43     int result = path != null ? path.hashCode() : 0;
44     result = 31 * result + (int) (targetSize ^ (targetSize >>> 32));
45     return result;
46   }
47 }
48