// Path: tweakable-annotations/src/main/java/com/jackwink/tweakable/exceptions/FailedToBuildPreferenceException.java
// public class FailedToBuildPreferenceException extends RuntimeException {
//     public static final long serialVersionUID = 0L;
// 
//     public FailedToBuildPreferenceException(String reason) {
//         super(reason);
//     }
// 
//     public FailedToBuildPreferenceException(String reason, Throwable rootCause) {
//         super(reason, rootCause);
//     }
// }
// 
// Path: tweakable-annotations/src/main/java/com/jackwink/tweakable/types/AbstractTweakableValue.java
// public abstract class AbstractTweakableValue<T> implements TweakableValue<T> {
//     public static final String BUNDLE_KEYATTR_KEY = "key";
//     public static final String BUNDLE_TITLE_KEY = "title";
//     public static final String BUNDLE_SUMMARY_KEY = "summary";
// 
//     public static final String BUNDLE_CATEGORY_KEY = "category";
//     public static final String BUNDLE_SCREEN_KEY = "screen";
// 
//     public static final String ROOT_SCREEN_KEY = "tweakable-values-root-screen";
//     public static final String ROOT_CATEGORY_KEY = "tweakable-values-root-category";
// 
// 
//     protected String mTitle;
//     protected String mKey;
//     protected String mSummary;
//     protected String mCategory;
//     protected String mScreen;
// 
//     @Override
//     public String getKey() {
//         return mKey;
//     }
// 
//     @Override
//     public String getTitle() {
//         return mTitle == null ? "ERROR" : mTitle;
//     }
// 
//     @Override
//     public String getSummary() {
//         return mSummary;
//     }
// 
//     @Override
//     public String getCategory() {
//         return mCategory;
//     }
// 
//     @Override
//     public String getScreen() {
//         return mScreen;
//     }
// 
//     public static String getDefaultString(String value, String defaultValue) {
//         if (value == null || value.isEmpty()) {
//             return defaultValue;
//         }
//         return value;
//     }
// }


import android.content.Context;
import android.os.Bundle;
import android.preference.DialogPreference;
import android.preference.Preference;
import android.util.Log;
import com.jackwink.tweakable.exceptions.FailedToBuildPreferenceException;
import com.jackwink.tweakable.types.AbstractTweakableValue;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
package com.jackwink.tweakable.builders;




/**
 *  Contains convenience methods for any {@link PreferenceBuilder} subclass
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public abstract class BasePreferenceBuilder<T extends Preference> implements PreferenceBuilder<T> {
    private static final String TAG = BasePreferenceBuilder.class.getSimpleName();

    public static final String BUNDLE_KEYATTR_KEY = AbstractTweakableValue.BUNDLE_KEYATTR_KEY;
    public static final String BUNDLE_TITLE_KEY = AbstractTweakableValue.BUNDLE_TITLE_KEY;
    public static final String BUNDLE_SUMMARY_KEY = AbstractTweakableValue.BUNDLE_SUMMARY_KEY;

    /* Builder set attributes */
    protected Map<String, Object> mAttributeMap = null;
    protected Context mContext = null;
    protected Object mDefaultValue = null;

    /**
     * Returns the value of a given attribute or throws an exception if it's not found
     *
     * @param attributeName Name of the user-provided attribute
     * @return Value of the provided {@code attributeName}
     * @throws FailedToBuildPreferenceException if bundle is missing an attribute
     */
    protected Object getRequiredAttribute(String attributeName) {
        if (!mAttributeMap.containsKey(attributeName)) {
            throw new FailedToBuildPreferenceException(
                    "Missing required attribute: " + attributeName);
        }
        return mAttributeMap.get(attributeName);
    }

    /**
     * Like the {@link #getRequiredAttribute(String)} method, except it returns {@code null} instead
     * of throwing an exception.
     *
     * @param attributeName Name of the user-provided attribute
     * @return Value of the provided {@code attributeName} or {@code null}
     */
    protected Object getOptionalAttribute(String attributeName) {
        if (!mAttributeMap.containsKey(attributeName)) {
            return null;
        }
        return mAttributeMap.get(attributeName);
    }

    /**
     * Sets the internal {@link Bundle} used to generate the preference object.
     * <p>The following values are required for all preferences:</p>
     * <ul>
     *     <li>
     *         {@link com.jackwink.tweakable.types.AbstractTweakableValue#BUNDLE_KEYATTR_KEY}
     *     </li>
     *     <li>
     *         {@link com.jackwink.tweakable.types.AbstractTweakableValue#BUNDLE_TITLE_KEY}
     *     </li>
     * </ul>
     * @param attributeMap Bundle containing values used to construct the preference
     * @return The updated builder
     */
// Path: tweakable-annotations/src/main/java/com/jackwink/tweakable/exceptions/FailedToBuildPreferenceException.java
// public class FailedToBuildPreferenceException extends RuntimeException {
//     public static final long serialVersionUID = 0L;
// 
//     public FailedToBuildPreferenceException(String reason) {
//         super(reason);
//     }
// 
//     public FailedToBuildPreferenceException(String reason, Throwable rootCause) {
//         super(reason, rootCause);
//     }
// }
// 
// Path: tweakable-annotations/src/main/java/com/jackwink/tweakable/types/AbstractTweakableValue.java
// public abstract class AbstractTweakableValue<T> implements TweakableValue<T> {
//     public static final String BUNDLE_KEYATTR_KEY = "key";
//     public static final String BUNDLE_TITLE_KEY = "title";
//     public static final String BUNDLE_SUMMARY_KEY = "summary";
// 
//     public static final String BUNDLE_CATEGORY_KEY = "category";
//     public static final String BUNDLE_SCREEN_KEY = "screen";
// 
//     public static final String ROOT_SCREEN_KEY = "tweakable-values-root-screen";
//     public static final String ROOT_CATEGORY_KEY = "tweakable-values-root-category";
// 
// 
//     protected String mTitle;
//     protected String mKey;
//     protected String mSummary;
//     protected String mCategory;
//     protected String mScreen;
// 
//     @Override
//     public String getKey() {
//         return mKey;
//     }
// 
//     @Override
//     public String getTitle() {
//         return mTitle == null ? "ERROR" : mTitle;
//     }
// 
//     @Override
//     public String getSummary() {
//         return mSummary;
//     }
// 
//     @Override
//     public String getCategory() {
//         return mCategory;
//     }
// 
//     @Override
//     public String getScreen() {
//         return mScreen;
//     }
// 
//     public static String getDefaultString(String value, String defaultValue) {
//         if (value == null || value.isEmpty()) {
//             return defaultValue;
//         }
//         return value;
//     }
// }


// Path: tweakable/src/main/java/com/jackwink/tweakable/builders/BasePreferenceBuilder.java
import android.content.Context;
import android.os.Bundle;
import android.preference.DialogPreference;
import android.preference.Preference;
import android.util.Log;
import com.jackwink.tweakable.exceptions.FailedToBuildPreferenceException;
import com.jackwink.tweakable.types.AbstractTweakableValue;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

package com.jackwink.tweakable.builders;




/**
 *  Contains convenience methods for any {@link PreferenceBuilder} subclass
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public abstract class BasePreferenceBuilder<T extends Preference> implements PreferenceBuilder<T> {
    private static final String TAG = BasePreferenceBuilder.class.getSimpleName();

    public static final String BUNDLE_KEYATTR_KEY = AbstractTweakableValue.BUNDLE_KEYATTR_KEY;
    public static final String BUNDLE_TITLE_KEY = AbstractTweakableValue.BUNDLE_TITLE_KEY;
    public static final String BUNDLE_SUMMARY_KEY = AbstractTweakableValue.BUNDLE_SUMMARY_KEY;

    /* Builder set attributes */
    protected Map<String, Object> mAttributeMap = null;
    protected Context mContext = null;
    protected Object mDefaultValue = null;

    /**
     * Returns the value of a given attribute or throws an exception if it's not found
     *
     * @param attributeName Name of the user-provided attribute
     * @return Value of the provided {@code attributeName}
     * @throws FailedToBuildPreferenceException if bundle is missing an attribute
     */
    protected Object getRequiredAttribute(String attributeName) {
        if (!mAttributeMap.containsKey(attributeName)) {
            throw new FailedToBuildPreferenceException(
                    "Missing required attribute: " + attributeName);
        }
        return mAttributeMap.get(attributeName);
    }

    /**
     * Like the {@link #getRequiredAttribute(String)} method, except it returns {@code null} instead
     * of throwing an exception.
     *
     * @param attributeName Name of the user-provided attribute
     * @return Value of the provided {@code attributeName} or {@code null}
     */
    protected Object getOptionalAttribute(String attributeName) {
        if (!mAttributeMap.containsKey(attributeName)) {
            return null;
        }
        return mAttributeMap.get(attributeName);
    }

    /**
     * Sets the internal {@link Bundle} used to generate the preference object.
     * <p>The following values are required for all preferences:</p>
     * <ul>
     *     <li>
     *         {@link com.jackwink.tweakable.types.AbstractTweakableValue#BUNDLE_KEYATTR_KEY}
     *     </li>
     *     <li>
     *         {@link com.jackwink.tweakable.types.AbstractTweakableValue#BUNDLE_TITLE_KEY}
     *     </li>
     * </ul>
     * @param attributeMap Bundle containing values used to construct the preference
     * @return The updated builder
     */
    public BasePreferenceBuilder<T> setBundle(Map<String, Object> attributeMap) {