tysonnorris commented on a change in pull request #2650: Apply standard scala 
formatting.
URL: 
https://github.com/apache/incubator-openwhisk/pull/2650#discussion_r134609473
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/common/Config.scala
 ##########
 @@ -42,113 +42,120 @@ import scala.util.Try
  * @param optionalProperties a Set of optional properties which may or not be 
defined.
  * @param env an optional environment to read from (defaults to sys.env).
  */
-class Config(
-    requiredProperties: Map[String, String],
-    optionalProperties: Set[String] = Set())(
-        env: Map[String, String] = sys.env)(
-            implicit logging: Logging) {
-
-    private val settings = getProperties().toMap.filter {
-        case (k, v) => requiredProperties.contains(k) ||
-            (optionalProperties.contains(k) && v != null)
-    }
+class Config(requiredProperties: Map[String, String], optionalProperties: 
Set[String] = Set())(
+    env: Map[String, String] = sys.env)(implicit logging: Logging) {
 
-    lazy val isValid: Boolean = Config.validateProperties(requiredProperties, 
settings)
-
-    /**
-     * Gets value for key if it exists else the empty string.
-     * The value of the override key will instead be returned if its value is 
present in the map.
-     *
-     * @param key to lookup
-     * @param overrideKey the property whose value will be returned if the map 
contains the override key.
-     * @return value for the key or the empty string if the key does not have 
a value/does not exist
-     */
-    def apply(key: String, overrideKey: String = ""): String = {
-        Try(settings(overrideKey)).orElse(Try(settings(key))).getOrElse("")
-    }
+  private val settings = getProperties().toMap.filter {
+    case (k, v) =>
+      requiredProperties.contains(k) ||
+        (optionalProperties.contains(k) && v != null)
+  }
 
-    /**
-     * Returns the value of a given key.
-     *
-     * @param key the property that has to be returned.
-     */
-    def getProperty(key: String): String = {
-        this(key)
-    }
+  lazy val isValid: Boolean =
+    Config.validateProperties(requiredProperties, settings)
 
-    /**
-     * Returns the value of a given key parsed as a double.
-     * If parsing fails, return the default value.
-     *
-     * @param key the property that has to be returned.
-     */
-    def getAsDouble(key: String, defaultValue: Double): Double = {
-        Try { getProperty(key).toDouble } getOrElse { defaultValue }
-    }
+  /**
+   * Gets value for key if it exists else the empty string.
+   * The value of the override key will instead be returned if its value is 
present in the map.
+   *
+   * @param key to lookup
+   * @param overrideKey the property whose value will be returned if the map 
contains the override key.
+   * @return value for the key or the empty string if the key does not have a 
value/does not exist
+   */
+  def apply(key: String, overrideKey: String = ""): String = {
+    Try(settings(overrideKey)).orElse(Try(settings(key))).getOrElse("")
+  }
 
-    /**
-     * Returns the value of a given key parsed as an integer.
-     * If parsing fails, return the default value.
-     *
-     * @param key the property that has to be returned.
-     */
-    def getAsInt(key: String, defaultValue: Int): Int = {
-        Try { getProperty(key).toInt } getOrElse { defaultValue }
-    }
+  /**
+   * Returns the value of a given key.
+   *
+   * @param key the property that has to be returned.
+   */
+  def getProperty(key: String): String = {
+    this(key)
+  }
+
+  /**
+   * Returns the value of a given key parsed as a double.
+   * If parsing fails, return the default value.
+   *
+   * @param key the property that has to be returned.
+   */
+  def getAsDouble(key: String, defaultValue: Double): Double = {
+    Try { getProperty(key).toDouble } getOrElse { defaultValue }
+  }
 
-    /**
-     * Converts the set of property to a string for debugging.
-     */
-    def mkString: String = settings.mkString("\n")
-
-    /**
-     * Loads the properties from the environment into a mutable map.
-     *
-     * @return a pair which is the Map defining the properties, and a boolean 
indicating whether validation succeeded.
-     */
-    protected def getProperties(): scala.collection.mutable.Map[String, 
String] = {
-        val required = scala.collection.mutable.Map[String, String]() ++= 
requiredProperties
-        Config.readPropertiesFromEnvironment(required, env)
-
-        // for optional value, assign them a default from the required 
properties list
-        // to prevent loss of a default value on a required property that may 
not otherwise be defined
-        val optional = scala.collection.mutable.Map[String, String]() ++= 
optionalProperties.map { k => k -> required.getOrElse(k, null) }
-        Config.readPropertiesFromEnvironment(optional, env)
-
-        required ++ optional
+  /**
+   * Returns the value of a given key parsed as an integer.
+   * If parsing fails, return the default value.
+   *
+   * @param key the property that has to be returned.
+   */
+  def getAsInt(key: String, defaultValue: Int): Int = {
+    Try { getProperty(key).toInt } getOrElse { defaultValue }
+  }
+
+  /**
+   * Converts the set of property to a string for debugging.
+   */
+  def mkString: String = settings.mkString("\n")
+
+  /**
+   * Loads the properties from the environment into a mutable map.
+   *
+   * @return a pair which is the Map defining the properties, and a boolean 
indicating whether validation succeeded.
+   */
+  protected def getProperties(): scala.collection.mutable.Map[String, String] 
= {
+    val required = scala.collection.mutable
+      .Map[String, String]() ++= requiredProperties
+    Config.readPropertiesFromEnvironment(required, env)
+
+    // for optional value, assign them a default from the required properties 
list
+    // to prevent loss of a default value on a required property that may not 
otherwise be defined
+    val optional = scala.collection.mutable
+      .Map[String, String]() ++= optionalProperties.map { k =>
 
 Review comment:
   another early wrapping?
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to