This is an automated email from the ASF dual-hosted git repository.

zuston pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/auron.git


The following commit(s) were added to refs/heads/master by this push:
     new 462490f6 [AURON #1339] Introduce AuronConfiguration (#1340)
462490f6 is described below

commit 462490f675282172d9e0c0368a3bc237212a92d8
Author: zhangmang <[email protected]>
AuthorDate: Fri Sep 26 15:15:56 2025 +0800

    [AURON #1339] Introduce AuronConfiguration (#1340)
---
 auron-core/pom.xml                                 |  65 ++++++++
 .../auron/configuration/AuronConfiguration.java    | 170 +++++++++++++++++++++
 .../apache/auron/configuration/ConfigOption.java   |  96 ++++++++++++
 .../apache/auron/configuration/ConfigOptions.java  | 148 ++++++++++++++++++
 .../java/org/apache/auron/util/Preconditions.java  |  64 ++++++++
 .../configuration/AuronConfigurationTest.java      |  51 +++++++
 .../auron/configuration/ConfigOptionTest.java      |  35 +++++
 .../configuration/MockAuronConfiguration.java      |  63 ++++++++
 pom.xml                                            |   1 +
 9 files changed, 693 insertions(+)

diff --git a/auron-core/pom.xml b/auron-core/pom.xml
new file mode 100644
index 00000000..fd07f7b0
--- /dev/null
+++ b/auron-core/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.auron</groupId>
+    <artifactId>auron-parent_${scalaVersion}</artifactId>
+    <version>${project.version}</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
+  <artifactId>auron-core</artifactId>
+  <packaging>jar</packaging>
+
+  <dependencies>
+
+    <!-- 'javax.annotation' classes like '@Nullable' -->
+    <dependency>
+      <groupId>com.google.code.findbugs</groupId>
+      <artifactId>jsr305</artifactId>
+      <version>1.3.9</version>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.13.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>prepare-test-jar</id>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+            <phase>test-compile</phase>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git 
a/auron-core/src/main/java/org/apache/auron/configuration/AuronConfiguration.java
 
b/auron-core/src/main/java/org/apache/auron/configuration/AuronConfiguration.java
new file mode 100644
index 00000000..33861fa8
--- /dev/null
+++ 
b/auron-core/src/main/java/org/apache/auron/configuration/AuronConfiguration.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.auron.configuration;
+
+import java.util.Optional;
+
+/**
+ * Auron configuration base class.
+ */
+public abstract class AuronConfiguration {
+
+    public abstract <T> Optional<T> getOptional(ConfigOption<T> option);
+
+    public abstract <T> Optional<T> getOptional(String key);
+
+    public <T> T get(ConfigOption<T> option) {
+        return getOptional(option).orElseGet(option::defaultValue);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a string.
+     *
+     * @param configOption The configuration option
+     * @return the (default) value associated with the given config option
+     */
+    public String getString(ConfigOption<String> configOption) {
+        return getOptional(configOption).orElseGet(configOption::defaultValue);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a string. 
If no value is mapped
+     * under any key of the option, it returns the specified default instead 
of the option's default
+     * value.
+     *
+     * @param configOption The configuration option
+     * @return the (default) value associated with the given config option
+     */
+    public String getString(ConfigOption<String> configOption, String 
overrideDefault) {
+        return getOptional(configOption).orElse(overrideDefault);
+    }
+
+    /**
+     * Returns the value associated with the given config option as an integer.
+     *
+     * @param configOption The configuration option
+     * @return the (default) value associated with the given config option
+     */
+    public int getInteger(ConfigOption<Integer> configOption) {
+        return getOptional(configOption).orElseGet(configOption::defaultValue);
+    }
+
+    /**
+     * Returns the value associated with the given config option as an 
integer. If no value is
+     * mapped under any key of the option, it returns the specified default 
instead of the option's
+     * default value.
+     *
+     * @param configOption The configuration option
+     * @param overrideDefault The value to return if no value was mapper for 
any key of the option
+     * @return the configured value associated with the given config option, 
or the overrideDefault
+     */
+    public int getInteger(ConfigOption<Integer> configOption, int 
overrideDefault) {
+        return getOptional(configOption).orElse(overrideDefault);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a long 
integer.
+     *
+     * @param configOption The configuration option
+     * @return the (default) value associated with the given config option
+     */
+    public long getLong(ConfigOption<Long> configOption) {
+        return getOptional(configOption).orElseGet(configOption::defaultValue);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a long 
integer. If no value is
+     * mapped under any key of the option, it returns the specified default 
instead of the option's
+     * default value.
+     *
+     * @param configOption The configuration option
+     * @param overrideDefault The value to return if no value was mapper for 
any key of the option
+     * @return the configured value associated with the given config option, 
or the overrideDefault
+     */
+    public long getLong(ConfigOption<Long> configOption, long overrideDefault) 
{
+        return getOptional(configOption).orElse(overrideDefault);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a boolean.
+     *
+     * @param configOption The configuration option
+     * @return the (default) value associated with the given config option
+     */
+    public boolean getBoolean(ConfigOption<Boolean> configOption) {
+        return getOptional(configOption).orElseGet(configOption::defaultValue);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a boolean. 
If no value is mapped
+     * under any key of the option, it returns the specified default instead 
of the option's default
+     * value.
+     *
+     * @param configOption The configuration option
+     * @param overrideDefault The value to return if no value was mapper for 
any key of the option
+     * @return the configured value associated with the given config option, 
or the overrideDefault
+     */
+    public boolean getBoolean(ConfigOption<Boolean> configOption, boolean 
overrideDefault) {
+        return getOptional(configOption).orElse(overrideDefault);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a float.
+     *
+     * @param configOption The configuration option
+     * @return the (default) value associated with the given config option
+     */
+    public float getFloat(ConfigOption<Float> configOption) {
+        return getOptional(configOption).orElseGet(configOption::defaultValue);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a float. 
If no value is mapped
+     * under any key of the option, it returns the specified default instead 
of the option's default
+     * value.
+     *
+     * @param configOption The configuration option
+     * @param overrideDefault The value to return if no value was mapper for 
any key of the option
+     * @return the configured value associated with the given config option, 
or the overrideDefault
+     */
+    public float getFloat(ConfigOption<Float> configOption, float 
overrideDefault) {
+        return getOptional(configOption).orElse(overrideDefault);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a {@code 
double}.
+     *
+     * @param configOption The configuration option
+     * @return the (default) value associated with the given config option
+     */
+    public double getDouble(ConfigOption<Double> configOption) {
+        return getOptional(configOption).orElseGet(configOption::defaultValue);
+    }
+
+    /**
+     * Returns the value associated with the given config option as a {@code 
double}. If no value is
+     * mapped under any key of the option, it returns the specified default 
instead of the option's
+     * default value.
+     *
+     * @param configOption The configuration option
+     * @param overrideDefault The value to return if no value was mapper for 
any key of the option
+     * @return the configured value associated with the given config option, 
or the overrideDefault
+     */
+    public double getDouble(ConfigOption<Double> configOption, double 
overrideDefault) {
+        return getOptional(configOption).orElse(overrideDefault);
+    }
+}
diff --git 
a/auron-core/src/main/java/org/apache/auron/configuration/ConfigOption.java 
b/auron-core/src/main/java/org/apache/auron/configuration/ConfigOption.java
new file mode 100644
index 00000000..3c93c4e5
--- /dev/null
+++ b/auron-core/src/main/java/org/apache/auron/configuration/ConfigOption.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.auron.configuration;
+
+import static org.apache.auron.util.Preconditions.checkNotNull;
+
+/**
+ * A {@code ConfigOption} describes a configuration parameter. It encapsulates 
the configuration
+ * key, and an optional default value for the configuration parameter.
+ * Refer to the design of the Flink engine.
+ *
+ * <p>{@code ConfigOptions} are built via the {@link ConfigOptions} class. 
Once created, a config
+ * option is immutable.
+ *
+ * @param <T> The type of value associated with the configuration option.
+ */
+public class ConfigOption<T> {
+
+    public static final String EMPTY_DESCRIPTION = "";
+
+    /** The current key for that config option. */
+    private final String key;
+
+    /** The default value for this option. */
+    private final T defaultValue;
+
+    /** The description for this option. */
+    private final String description;
+
+    /**
+     * Type of the value that this ConfigOption describes.
+     *
+     * <ul>
+     *   <li>typeClass == atomic class (e.g. {@code Integer.class}) -> {@code 
ConfigOption<Integer>}
+     *   <li>typeClass == {@code Map.class} -> {@code ConfigOption<Map<String, 
String>>}
+     *   <li>typeClass == atomic class and isList == true for {@code 
ConfigOption<List<Integer>>}
+     * </ul>
+     */
+    private final Class<?> clazz;
+
+    /**
+     * Creates a new config option with fallback keys.
+     *
+     * @param key The current key for that config option
+     * @param clazz describes type of the ConfigOption, see description of the 
clazz field
+     * @param description Description for that option
+     * @param defaultValue The default value for this option
+     */
+    ConfigOption(String key, Class<?> clazz, T defaultValue, String 
description) {
+        this.key = checkNotNull(key);
+        this.description = description;
+        this.defaultValue = defaultValue;
+        this.clazz = checkNotNull(clazz);
+    }
+
+    /**
+     * Gets the configuration key.
+     *
+     * @return The configuration key
+     */
+    public String key() {
+        return key;
+    }
+
+    /**
+     * Checks if this option has a default value.
+     *
+     * @return True if it has a default value, false if not.
+     */
+    public boolean hasDefaultValue() {
+        return defaultValue != null;
+    }
+
+    /**
+     * Returns the default value, or null, if there is no default value.
+     *
+     * @return The default value, or null.
+     */
+    public T defaultValue() {
+        return defaultValue;
+    }
+}
diff --git 
a/auron-core/src/main/java/org/apache/auron/configuration/ConfigOptions.java 
b/auron-core/src/main/java/org/apache/auron/configuration/ConfigOptions.java
new file mode 100644
index 00000000..517eb926
--- /dev/null
+++ b/auron-core/src/main/java/org/apache/auron/configuration/ConfigOptions.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.auron.configuration;
+
+import static org.apache.auron.util.Preconditions.checkNotNull;
+
+/**
+ * Refer to the design of the Flink engine.
+ * {@code ConfigOptions} are used to build a {@link ConfigOption}. The option 
is typically built in
+ * one of the following pattern:
+ *
+ * <pre>{@code
+ * // simple string-valued option with a default value
+ * ConfigOption<String> tempDirs = ConfigOptions
+ *     .key("tmp.dir")
+ *     .stringType()
+ *     .defaultValue("/tmp");
+ *
+ * // simple integer-valued option with a default value
+ * ConfigOption<Integer> batchSize = ConfigOptions
+ *     .key("batch.size")
+ *     .intType()
+ *     .defaultValue(100);
+ *
+ * // option with no default value
+ * ConfigOption<String> userName = ConfigOptions
+ *     .key("user.name")
+ *     .stringType()
+ *     .noDefaultValue();
+ * }</pre>
+ */
+public class ConfigOptions {
+
+    /**
+     * Starts building a new {@link ConfigOption}.
+     *
+     * @param key The key for the config option.
+     * @return The builder for the config option with the given key.
+     */
+    public static OptionBuilder key(String key) {
+        checkNotNull(key);
+        return new OptionBuilder(key);
+    }
+
+    // ------------------------------------------------------------------------
+
+    /**
+     * The option builder is used to create a {@link ConfigOption}. It is 
instantiated via {@link
+     * ConfigOptions#key(String)}.
+     */
+    public static final class OptionBuilder {
+
+        /** The key for the config option. */
+        private final String key;
+
+        /**
+         * Creates a new OptionBuilder.
+         *
+         * @param key The key for the config option
+         */
+        OptionBuilder(String key) {
+            this.key = key;
+        }
+
+        /** Defines that the value of the option should be of {@link Boolean} 
type. */
+        public TypedConfigOptionBuilder<Boolean> booleanType() {
+            return new TypedConfigOptionBuilder<>(key, Boolean.class);
+        }
+
+        /** Defines that the value of the option should be of {@link Integer} 
type. */
+        public TypedConfigOptionBuilder<Integer> intType() {
+            return new TypedConfigOptionBuilder<>(key, Integer.class);
+        }
+
+        /** Defines that the value of the option should be of {@link Long} 
type. */
+        public TypedConfigOptionBuilder<Long> longType() {
+            return new TypedConfigOptionBuilder<>(key, Long.class);
+        }
+
+        /** Defines that the value of the option should be of {@link Float} 
type. */
+        public TypedConfigOptionBuilder<Float> floatType() {
+            return new TypedConfigOptionBuilder<>(key, Float.class);
+        }
+
+        /** Defines that the value of the option should be of {@link Double} 
type. */
+        public TypedConfigOptionBuilder<Double> doubleType() {
+            return new TypedConfigOptionBuilder<>(key, Double.class);
+        }
+
+        /** Defines that the value of the option should be of {@link String} 
type. */
+        public TypedConfigOptionBuilder<String> stringType() {
+            return new TypedConfigOptionBuilder<>(key, String.class);
+        }
+    }
+
+    /**
+     * Builder for {@link ConfigOption} with a defined atomic type.
+     *
+     * @param <T> atomic type of the option
+     */
+    public static class TypedConfigOptionBuilder<T> {
+        private final String key;
+        private final Class<T> clazz;
+
+        TypedConfigOptionBuilder(String key, Class<T> clazz) {
+            this.key = key;
+            this.clazz = clazz;
+        }
+
+        /**
+         * Creates a ConfigOption with the given default value.
+         *
+         * @param value The default value for the config option
+         * @return The config option with the default value.
+         */
+        public ConfigOption<T> defaultValue(T value) {
+            return new ConfigOption<>(key, clazz, value, 
ConfigOption.EMPTY_DESCRIPTION);
+        }
+
+        /**
+         * Creates a ConfigOption without a default value.
+         *
+         * @return The config option without a default value.
+         */
+        public ConfigOption<T> noDefaultValue() {
+            return new ConfigOption<>(key, clazz, null, 
ConfigOption.EMPTY_DESCRIPTION);
+        }
+    }
+
+    // ------------------------------------------------------------------------
+
+    /** Not intended to be instantiated. */
+    private ConfigOptions() {}
+}
diff --git a/auron-core/src/main/java/org/apache/auron/util/Preconditions.java 
b/auron-core/src/main/java/org/apache/auron/util/Preconditions.java
new file mode 100644
index 00000000..2144f88f
--- /dev/null
+++ b/auron-core/src/main/java/org/apache/auron/util/Preconditions.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.auron.util;
+
+import javax.annotation.Nullable;
+
+/**
+ * A collection of static utility methods to validate input.
+ *
+ * <p>This class is modelled after Google Guava's Preconditions class, and 
partly takes code from
+ * that class. We add this code to the Auron code base in order to reduce 
external dependencies.
+ */
+public class Preconditions {
+
+    // ------------------------------------------------------------------------
+    //  Null checks
+    // ------------------------------------------------------------------------
+
+    /**
+     * Ensures that the given object reference is not null. Upon violation, a 
{@code
+     * NullPointerException} with no message is thrown.
+     *
+     * @param reference The object reference
+     * @return The object reference itself (generically typed).
+     * @throws NullPointerException Thrown, if the passed reference was null.
+     */
+    public static <T> T checkNotNull(@Nullable T reference) {
+        if (reference == null) {
+            throw new NullPointerException();
+        }
+        return reference;
+    }
+
+    /**
+     * Ensures that the given object reference is not null. Upon violation, a 
{@code
+     * NullPointerException} with the given message is thrown.
+     *
+     * @param reference The object reference
+     * @param errorMessage The message for the {@code NullPointerException} 
that is thrown if the
+     *     check fails.
+     * @return The object reference itself (generically typed).
+     * @throws NullPointerException Thrown, if the passed reference was null.
+     */
+    public static <T> T checkNotNull(@Nullable T reference, @Nullable String 
errorMessage) {
+        if (reference == null) {
+            throw new NullPointerException(String.valueOf(errorMessage));
+        }
+        return reference;
+    }
+}
diff --git 
a/auron-core/src/test/java/org/apache/auron/configuration/AuronConfigurationTest.java
 
b/auron-core/src/test/java/org/apache/auron/configuration/AuronConfigurationTest.java
new file mode 100644
index 00000000..14c0b0b3
--- /dev/null
+++ 
b/auron-core/src/test/java/org/apache/auron/configuration/AuronConfigurationTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.auron.configuration;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * This is a test class for {@link AuronConfiguration}.
+ */
+public class AuronConfigurationTest {
+
+    private MockAuronConfiguration config;
+
+    @Before
+    public void setUp() {
+        config = new MockAuronConfiguration();
+        
config.addConfig(MockAuronConfiguration.STRING_WITHOUT_DEFAULT_CONFIG_OPTION.key(),
 "str1");
+        config.addConfig(MockAuronConfiguration.INT_CONFIG_OPTION.key(), 100);
+        config.addConfig(MockAuronConfiguration.BOOLEAN_CONFIG_OPTION.key(), 
false);
+        config.addConfig(MockAuronConfiguration.DOUBLE_CONFIG_OPTION.key(), 
99.9);
+        config.addConfig(MockAuronConfiguration.LONG_CONFIG_OPTION.key(), 
10000000000L);
+        config.addConfig(MockAuronConfiguration.FLOAT_CONFIG_OPTION.key(), 
1.2f);
+    }
+
+    @Test
+    public void testGetConfig() {
+        Assert.assertEquals("str1", 
config.get(MockAuronConfiguration.STRING_WITHOUT_DEFAULT_CONFIG_OPTION));
+        Assert.assertEquals("zm", 
config.get(MockAuronConfiguration.STRING_CONFIG_OPTION));
+        Assert.assertEquals(100, 
config.getInteger(MockAuronConfiguration.INT_CONFIG_OPTION));
+        Assert.assertEquals(false, 
config.get(MockAuronConfiguration.BOOLEAN_CONFIG_OPTION));
+        Assert.assertEquals(99.9, 
config.get(MockAuronConfiguration.DOUBLE_CONFIG_OPTION), 0.0000000001);
+        Assert.assertEquals(10000000000L, 
config.getLong(MockAuronConfiguration.LONG_CONFIG_OPTION));
+        Assert.assertEquals(1.2f, 
config.get(MockAuronConfiguration.FLOAT_CONFIG_OPTION), 0.0000000001);
+    }
+}
diff --git 
a/auron-core/src/test/java/org/apache/auron/configuration/ConfigOptionTest.java 
b/auron-core/src/test/java/org/apache/auron/configuration/ConfigOptionTest.java
new file mode 100644
index 00000000..e71c34cd
--- /dev/null
+++ 
b/auron-core/src/test/java/org/apache/auron/configuration/ConfigOptionTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.auron.configuration;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/** Tests for the {@link ConfigOption}. */
+public class ConfigOptionTest {
+
+    @Test
+    public void testConfigOption() {
+        ConfigOption<String> keyOption = 
ConfigOptions.key("key").stringType().noDefaultValue();
+        Assert.assertEquals("key", keyOption.key());
+        Assert.assertEquals(null, keyOption.defaultValue());
+        Assert.assertEquals(false, keyOption.hasDefaultValue());
+        ConfigOption<Boolean> booleanOption =
+                ConfigOptions.key("boolean").booleanType().defaultValue(true);
+        Assert.assertEquals(true, booleanOption.defaultValue());
+    }
+}
diff --git 
a/auron-core/src/test/java/org/apache/auron/configuration/MockAuronConfiguration.java
 
b/auron-core/src/test/java/org/apache/auron/configuration/MockAuronConfiguration.java
new file mode 100644
index 00000000..85fbbd88
--- /dev/null
+++ 
b/auron-core/src/test/java/org/apache/auron/configuration/MockAuronConfiguration.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.auron.configuration;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+public class MockAuronConfiguration extends AuronConfiguration {
+
+    public static final ConfigOption<String> STRING_CONFIG_OPTION =
+            ConfigOptions.key("string").stringType().defaultValue("zm");
+
+    public static final ConfigOption<String> 
STRING_WITHOUT_DEFAULT_CONFIG_OPTION =
+            
ConfigOptions.key("string_without_default").stringType().noDefaultValue();
+
+    public static final ConfigOption<Integer> INT_CONFIG_OPTION =
+            ConfigOptions.key("int").intType().defaultValue(1);
+
+    public static final ConfigOption<Long> LONG_CONFIG_OPTION =
+            ConfigOptions.key("long").longType().defaultValue(1L);
+
+    public static final ConfigOption<Boolean> BOOLEAN_CONFIG_OPTION =
+            ConfigOptions.key("boolean").booleanType().defaultValue(true);
+
+    public static final ConfigOption<Double> DOUBLE_CONFIG_OPTION =
+            ConfigOptions.key("double").doubleType().defaultValue(1.0);
+
+    public static final ConfigOption<Float> FLOAT_CONFIG_OPTION =
+            ConfigOptions.key("float").floatType().defaultValue(1.0f);
+
+    private Map<String, Object> configMap = new HashMap<>();
+
+    public MockAuronConfiguration() {}
+
+    public void addConfig(String key, Object value) {
+        configMap.put(key, value);
+    }
+
+    @Override
+    public <T> Optional<T> getOptional(ConfigOption<T> option) {
+        return Optional.ofNullable((T) configMap.get(option.key()));
+    }
+
+    @Override
+    public <T> Optional<T> getOptional(String key) {
+        return Optional.ofNullable((T) configMap.get(key));
+    }
+}
diff --git a/pom.xml b/pom.xml
index 9af72714..36b7b33f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,6 +34,7 @@
   <url>https://github.com/apache/auron.git</url>
 
   <modules>
+    <module>auron-core</module>
     <module>common</module>
     <module>spark-version-annotation-macros</module>
     <module>spark-extension</module>

Reply via email to