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 enum ComparatorType { 9 JAVA_COMPARATOR((byte)0x0), 10 JAVA_NATIVE_COMPARATOR_WRAPPER((byte)0x1); 11 12 private final byte value; 13 ComparatorType(final byte value)14 ComparatorType(final byte value) { 15 this.value = value; 16 } 17 18 /** 19 * <p>Returns the byte value of the enumerations value.</p> 20 * 21 * @return byte representation 22 */ getValue()23 byte getValue() { 24 return value; 25 } 26 27 /** 28 * <p>Get the ComparatorType enumeration value by 29 * passing the byte identifier to this method.</p> 30 * 31 * @param byteIdentifier of ComparatorType. 32 * 33 * @return ComparatorType instance. 34 * 35 * @throws IllegalArgumentException if the comparator type for the byteIdentifier 36 * cannot be found 37 */ getComparatorType(final byte byteIdentifier)38 static ComparatorType getComparatorType(final byte byteIdentifier) { 39 for (final ComparatorType comparatorType : ComparatorType.values()) { 40 if (comparatorType.getValue() == byteIdentifier) { 41 return comparatorType; 42 } 43 } 44 45 throw new IllegalArgumentException( 46 "Illegal value provided for ComparatorType."); 47 } 48 } 49