// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Represents an instance of an application config with a specific configId. *
* An instance of this class contains all values (represented by Nodes) for the config object as it * is the superclass of the generated config class used by the client. */ public abstract class ConfigInstance extends InnerNode { public interface Builder extends ConfigBuilder { /** * Dispatches a getConfig() call if this instance's producer is of the right type * * @param producer a config producer * @return true if this instance's producer was the correct type, and hence a getConfig call was dispatched */ boolean dispatchGetConfig(Producer producer); String getDefName(); String getDefNamespace(); String getDefMd5(); /** Returns true if this instance should be applied on restart, false if it should be applied immediately */ default boolean getApplyOnRestart() { return false; } default void setApplyOnRestart(boolean applyOnRestart) { throw new java.lang.UnsupportedOperationException(); } } public interface Producer {} @SuppressWarnings("unused") // Used by reflection from ConfigInstanceUtil String configId; /** * Gets the name of the given config instance */ public static String getDefName(Class> type) { return getStaticStringField(type, "CONFIG_DEF_NAME"); } /** * Gets the namespace of the given config instance */ public static String getDefNamespace(Class> type) { return getStaticStringField(type, "CONFIG_DEF_NAMESPACE"); } /** * Returns the serialized representation of the given node. *
* Declared static, instead of InnerNode member, to avoid a public 0-arg method with a commonly used name.
*
* @param node The inner node
* @return a list of strings, containing the serialized representation of this config
*/
public static List