// Copyright 2016 Yahoo Inc.
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms.
package com.yahoo.bard.webservice.config;

/**
 * Feature flags bind an object to a system configuration name.
 */
public interface FeatureFlag {

    /**
     * Returns the name of a specific flag included in a class that implements this interface.
     * When it is implemented by an Enum class then the method {@code name} that is available in the Enum implicitly
     * implements this method of the interface
     *
     * @return The name of the enumeration instance.
     */
    String name();

    /**
     * Returns the simple property name of this feature flag.
     *
     * @return The name of the feature flag.
     */
    String getName();

    /**
     * Returns whether the feature flag is activated.
     *
     * @return The status of the feature flag.
     */
    boolean isOn();


    /**
     * Returns whether the feature flag has been configured.
     *
     * @return true if the feature flag has been configured.
     */
    default boolean isSet() {
        SystemConfig systemConfig = SystemConfigProvider.getInstance();
        try {
            return systemConfig.getStringProperty(systemConfig.getPackageVariableName(getName())) != null;
        } catch (SystemConfigException exception) {
            return false;
        }
    }

    /**
     * Sets the status of the feature flag.
     *
     * @param newValue  The new status of the feature flag.
     */
    void setOn(Boolean newValue);

    /**
     * Restores the feature flag to the startup state (if supported by the underlying conf mechanism).
     */
    void reset();
}

@@ -181,16 +181,49 @@
 onfig;%0A%0A
+import org.slf4j.LoggerFactory;%0A%0A
 /**%0A * F
@@ -1716,24 +1716,32 @@
      */%0A    
+default 
 void reset()
@@ -1740,12 +1740,338 @@
  reset()
-;
+ %7B%0A        String message = String.format(%0A                %22Current implementation of FeatureFlag: %25s does not support reset operation.%22,%0A                this.getClass().getSimpleName()%0A        );%0A        LoggerFactory.getLogger(FeatureFlag.class).error(message);%0A        throw new UnsupportedOperationException(message);%0A    %7D
 %0A%7D%0A

Add default implementation to feature flag reset operation (#481)