snazy commented on code in PR #282:
URL: https://github.com/apache/polaris/pull/282#discussion_r1760661130


##########
polaris-core/src/main/java/org/apache/polaris/core/PolarisConfiguration.java:
##########
@@ -19,89 +19,55 @@
 package org.apache.polaris.core;
 
 import java.util.Optional;
+import org.apache.polaris.immutables.PolarisImmutable;
+import org.immutables.value.Value;
 
-public class PolarisConfiguration<T> {
-
-  public final String key;
-  public final String description;
-  public final T defaultValue;
-  private final Optional<String> catalogConfigImpl;
-  private final Class<T> typ;
-
-  @SuppressWarnings("unchecked")
-  public PolarisConfiguration(
-      String key, String description, T defaultValue, Optional<String> 
catalogConfig) {
-    this.key = key;
-    this.description = description;
-    this.defaultValue = defaultValue;
-    this.catalogConfigImpl = catalogConfig;
-    this.typ = (Class<T>) defaultValue.getClass();
-  }
+@PolarisImmutable
+public interface PolarisConfiguration<T> {
 
-  public boolean hasCatalogConfig() {
-    return catalogConfigImpl.isPresent();
-  }
+  String key();
+
+  String description();
+
+  T defaultValue();
+
+  Optional<String> catalogConfig();
 
-  public String catalogConfig() {
-    return catalogConfigImpl.orElseThrow(
-        () ->
-            new IllegalStateException(
-                "Attempted to read a catalog config key from a configuration 
that doesn't have one."));
+  @Value.Derived
+  default boolean hasCatalogConfig() {
+    return catalogConfig().isPresent();
   }
 
-  T cast(Object value) {
-    return this.typ.cast(value);
+  @Value.Lazy

Review Comment:
   Err, I meant - doesn't need to be stored.
   ```suggestion
     @Value.NonAttribute
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to