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 /**
9  * The Thread Pool priority.
10  */
11 public enum Priority {
12   BOTTOM((byte) 0x0),
13   LOW((byte) 0x1),
14   HIGH((byte)0x2),
15   TOTAL((byte)0x3);
16 
17   private final byte value;
18 
Priority(final byte value)19   Priority(final byte value) {
20     this.value = value;
21   }
22 
23   /**
24    * <p>Returns the byte value of the enumerations value.</p>
25    *
26    * @return byte representation
27    */
getValue()28   byte getValue() {
29     return value;
30   }
31 
32   /**
33    * Get Priority by byte value.
34    *
35    * @param value byte representation of Priority.
36    *
37    * @return {@link org.rocksdb.Priority} instance.
38    * @throws java.lang.IllegalArgumentException if an invalid
39    *     value is provided.
40    */
getPriority(final byte value)41   static Priority getPriority(final byte value) {
42     for (final Priority priority : Priority.values()) {
43       if (priority.getValue() == value){
44         return priority;
45       }
46     }
47     throw new IllegalArgumentException("Illegal value provided for Priority.");
48   }
49 }
50