Correct javadoc reference
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / common / actor / AbstractConfig.java
index 3a66aa1181a509feb48305af1c3b079712ff0676..976d48d270c8b9fcf14706f3bdfd1cb41a05938d 100644 (file)
@@ -1,17 +1,24 @@
+/*
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 package org.opendaylight.controller.cluster.common.actor;
 
 import com.google.common.base.Preconditions;
 import com.typesafe.config.Config;
 import com.typesafe.config.ConfigFactory;
-
 import java.util.HashMap;
 import java.util.Map;
 
 public abstract class AbstractConfig implements UnifiedConfig {
 
-    private Config config;
+    private final Config config;
 
-    public AbstractConfig(Config config){
+    public AbstractConfig(Config config) {
         this.config = config;
     }
 
@@ -20,28 +27,31 @@ public abstract class AbstractConfig implements UnifiedConfig {
         return config;
     }
 
-    public static abstract class Builder<T extends Builder>{
+    public abstract static class Builder<T extends Builder<T>> {
         protected Map<String, Object> configHolder;
         protected Config fallback;
 
         private final String actorSystemName;
 
-        public Builder(String actorSystemName){
+        public Builder(String actorSystemName) {
             Preconditions.checkArgument(actorSystemName != null, "Actor system name must not be null");
             this.actorSystemName = actorSystemName;
             configHolder = new HashMap<>();
         }
 
-        public T withConfigReader(AkkaConfigurationReader reader){
+        @SuppressWarnings("unchecked")
+        public T withConfigReader(AkkaConfigurationReader reader) {
             fallback = reader.read().getConfig(actorSystemName);
             return (T)this;
         }
 
-        protected Config merge(){
-            if (fallback == null)
-                fallback = ConfigFactory.load().getConfig(actorSystemName);
+        protected Config merge() {
+            Config config = ConfigFactory.parseMap(configHolder);
+            if (fallback != null) {
+                config = config.withFallback(fallback);
+            }
 
-            return ConfigFactory.parseMap(configHolder).withFallback(fallback);
+            return config;
         }
     }
 }