blob: d2cea952f95d88b5bd4fd62d5d8bcc7590b86bb6 [file] [log] [blame]
package {package_name};
import java.util.HashMap;
import java.util.Map;
/** @hide */
public class FakeFeatureFlagsImpl implements FeatureFlags \{
public FakeFeatureFlagsImpl() \{
resetAll();
}
{{ for item in class_elements}}
@Override
public boolean {item.method_name}() \{
return getValue(Flags.FLAG_{item.flag_name_constant_suffix});
}
{{ endfor}}
public void setFlag(String flagName, boolean value) \{
if (!this.mFlagMap.containsKey(flagName)) \{
throw new IllegalArgumentException("no such flag " + flagName);
}
this.mFlagMap.put(flagName, value);
}
public void resetAll() \{
for (Map.Entry entry : mFlagMap.entrySet()) \{
entry.setValue(null);
}
}
private boolean getValue(String flagName) \{
Boolean value = this.mFlagMap.get(flagName);
if (value == null) \{
throw new IllegalArgumentException(flagName + " is not set");
}
return value;
}
private Map<String, Boolean> mFlagMap = new HashMap<>(
Map.ofEntries(
{{-for item in class_elements}}
Map.entry(Flags.FLAG_{item.flag_name_constant_suffix}, false)
{{ -if not @last }},{{ endif }}
{{ -endfor }}
)
);
}