Class Config


  • public class Config
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> java.util.Optional<T> getOptionalValue​(java.lang.String key, java.lang.Class<T> valueType)
      Retrieve a value from properties file.
      <T> T getValue​(java.lang.String key, java.lang.Class<T> valueType)
      Retrieve a value from properties file.
      static Config main()
      Retrieve a facade for the main config.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • main

        public static Config main()
        Retrieve a facade for the main config.
        Returns:
        interaction helper for 'main.properties' config
      • getValue

        public <T> T getValue​(java.lang.String key,
                              java.lang.Class<T> valueType)
        Retrieve a value from properties file.
        Type Parameters:
        T - the value type.
        Parameters:
        key - the name of the corresponding key which value to retrieve
        valueType - the expected type of the value to be retrieved
        Returns:
        the actual value
        Throws:
        java.lang.IllegalArgumentException - if the given key does not exist
        java.lang.ClassCastException - if the retrieved value cannot be cast to `valueType` type
      • getOptionalValue

        public <T> java.util.Optional<T> getOptionalValue​(java.lang.String key,
                                                          java.lang.Class<T> valueType)
        Retrieve a value from properties file.
        Type Parameters:
        T - the type of the resulting value.
        Parameters:
        key - the name of the corresponding key which value to retrieve
        valueType - the expected type of the value to be retrieved
        Returns:
        the actual value or Optional.empty() if the key is not present
        Throws:
        java.io.UncheckedIOException - if the given properties file does not exist/not accessible
        java.lang.ClassCastException - if the retrieved value cannot be cast to `valueType` type