package com.hivedi.devconfig;

import android.support.annotation.NonNull;

import java.io.File;
import java.util.ArrayList;

public abstract class BaseDevConfig {

	private ArrayList<Boolean> configs = new ArrayList<>();
	private ArrayList<String> customConfigs = new ArrayList<>();

	public abstract int getBoolConfigCount();
	public abstract boolean getDefaultValue(int configIndex);
	public abstract @NonNull File getConfigFile();
	public abstract @NonNull String getConfigKey();
	public long getConfigMaxFileRead() {
		return 20 * 1024;
	}

	public void addConfig(boolean value) {
		configs.add(value);
	}

	public boolean getBoolConfig(int idx) {
		try {
			return configs.get(idx);
		} catch (IndexOutOfBoundsException e) {
			return getDefaultValue(idx);
		}
	}

	public void addConfig(String value) {
		customConfigs.add(value);
	}

	public String getCustomConfig(int idx) {
		return customConfigs.get(idx);
	}

	@Override
	public String toString() {
		String res = "";

		for(int i=0; i<configs.size(); i++) {
			res += "CONFIG[" + i + "]=" + configs.get(i) + ", ";
		}

		for(int i=0; i<customConfigs.size(); i++) {
			res += "CONFIG_STR[" + i + "]=" + customConfigs.get(i) + ", ";
		}

		return res.length() > 0 ? res.substring(0, res.length() - 2) : res;
	}
}

@@ -66,16 +66,60 @@
 NonNull;
+%0Aimport android.support.annotation.Nullable;
 %0A%0Aimport
@@ -870,32 +870,43 @@
 add(value);%0A%09%7D%0A%0A
+%09@Nullable%0A
 %09public String g
@@ -927,24 +927,33 @@
 (int idx) %7B%0A
+%09%09try %7B%0A%09
 %09%09return cus
@@ -973,16 +973,78 @@
 t(idx);%0A
+%09%09%7D catch (IndexOutOfBoundsException e) %7B%0A%09%09%09return null;%0A%09%09%7D%0A
 %09%7D%0A%0A%09@Ov

Handle exception when get custom config