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 public enum TableFileCreationReason {
9   FLUSH((byte) 0x00),
10   COMPACTION((byte) 0x01),
11   RECOVERY((byte) 0x02),
12   MISC((byte) 0x03);
13 
14   private final byte value;
15 
TableFileCreationReason(final byte value)16   TableFileCreationReason(final byte value) {
17     this.value = value;
18   }
19 
20   /**
21    * Get the internal representation.
22    *
23    * @return the internal representation
24    */
getValue()25   byte getValue() {
26     return value;
27   }
28 
29   /**
30    * Get the TableFileCreationReason from the internal representation value.
31    *
32    * @return the table file creation reason.
33    *
34    * @throws IllegalArgumentException if the value is unknown.
35    */
fromValue(final byte value)36   static TableFileCreationReason fromValue(final byte value) {
37     for (final TableFileCreationReason tableFileCreationReason : TableFileCreationReason.values()) {
38       if (tableFileCreationReason.value == value) {
39         return tableFileCreationReason;
40       }
41     }
42 
43     throw new IllegalArgumentException(
44         "Illegal value provided for TableFileCreationReason: " + value);
45   }
46 }
47