2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.common.actor;
11 import com.google.common.base.Preconditions;
12 import com.typesafe.config.Config;
13 import com.typesafe.config.ConfigFactory;
14 import java.util.HashMap;
17 public abstract class AbstractConfig implements UnifiedConfig {
19 private final Config config;
21 public AbstractConfig(Config config) {
30 public abstract static class Builder<T extends Builder<T>> {
31 protected Map<String, Object> configHolder;
32 protected Config fallback;
34 private final String actorSystemName;
36 public Builder(String actorSystemName) {
37 Preconditions.checkArgument(actorSystemName != null, "Actor system name must not be null");
38 this.actorSystemName = actorSystemName;
39 configHolder = new HashMap<>();
42 @SuppressWarnings("unchecked")
43 public T withConfigReader(AkkaConfigurationReader reader) {
44 fallback = reader.read().getConfig(actorSystemName);
48 protected Config merge() {
49 Config config = ConfigFactory.parseMap(configHolder);
50 if (fallback != null) {
51 config = config.withFallback(fallback);