From 52626f10b106c86774ff8d64b466f7dc658f0bb2 Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Mon, 8 Nov 2021 08:19:54 -0800 Subject: [PATCH] Restore Java 7 Compatibility (#9103) Summary: RocksDB should still compile on Java 7. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9103 Reviewed By: pdillinger Differential Revision: D32067561 Pulled By: mrambacher fbshipit-source-id: bbe9c18c8007ab3e113de4add56a84c9bde61c8e --- .../main/java/org/rocksdb/AbstractMutableOptions.java | 7 ++----- java/src/main/java/org/rocksdb/CompressionType.java | 10 +++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/java/src/main/java/org/rocksdb/AbstractMutableOptions.java b/java/src/main/java/org/rocksdb/AbstractMutableOptions.java index b0a5aee9a..a5af80b27 100644 --- a/java/src/main/java/org/rocksdb/AbstractMutableOptions.java +++ b/java/src/main/java/org/rocksdb/AbstractMutableOptions.java @@ -341,11 +341,8 @@ public abstract class AbstractMutableOptions { return setIntArray(key, value); case ENUM: - final Optional compressionType = - CompressionType.getFromInternal(valueStr); - if (compressionType.isPresent()) { - return setEnum(key, compressionType.get()); - } + final CompressionType compressionType = CompressionType.getFromInternal(valueStr); + return setEnum(key, compressionType); } throw new IllegalStateException(key + " has unknown value type: " + key.getValueType()); diff --git a/java/src/main/java/org/rocksdb/CompressionType.java b/java/src/main/java/org/rocksdb/CompressionType.java index 89ea638ca..d1d73d51a 100644 --- a/java/src/main/java/org/rocksdb/CompressionType.java +++ b/java/src/main/java/org/rocksdb/CompressionType.java @@ -5,8 +5,6 @@ package org.rocksdb; -import java.util.Optional; - /** * Enum CompressionType * @@ -81,13 +79,15 @@ public enum CompressionType { * * @return CompressionType instance (optional) */ - public static Optional getFromInternal(final String internalName) { + static CompressionType getFromInternal(final String internalName) { for (final CompressionType compressionType : CompressionType.values()) { if (compressionType.internalName_.equals(internalName)) { - return Optional.of(compressionType); + return compressionType; } } - return Optional.empty(); + + throw new IllegalArgumentException( + "Illegal internalName '" + internalName + " ' provided for CompressionType."); } /**