<commit_before>package fr.simon.marquis.preferencesmanager.model;

public enum PreferenceType {
 BOOLEAN, STRING, INT, FLOAT, LONG, STRINGSET
}<commit_msg>PreferenceType is now fully described and usable<commit_after>/*
 * Copyright (C) 2013 <NAME> (http://www.simon-marquis.fr)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package fr.simon.marquis.preferencesmanager.model;

import java.util.Set;

import fr.simon.marquis.preferencesmanager.R;

public enum PreferenceType {
	BOOLEAN(R.layout.dialog_pref_boolean_add,
			R.layout.dialog_pref_boolean_edit, R.string.title_add_boolean,
			R.string.title_edit_boolean, R.drawable.card_blueborder), STRING(
			R.layout.dialog_pref_string_add, R.layout.dialog_pref_string_edit,
			R.string.title_add_string, R.string.title_edit_string,
			R.drawable.card_goldborder), INT(R.layout.dialog_pref_integer_add,
			R.layout.dialog_pref_integer_edit, R.string.title_add_int,
			R.string.title_edit_int, R.drawable.card_greenborder), FLOAT(
			R.layout.dialog_pref_float_add, R.layout.dialog_pref_float_edit,
			R.string.title_add_float, R.string.title_edit_float,
			R.drawable.card_tealborder), LONG(R.layout.dialog_pref_integer_add,
			R.layout.dialog_pref_integer_edit, R.string.title_add_long,
			R.string.title_edit_long, R.drawable.card_purpleborder), STRINGSET(
			R.layout.dialog_pref_stringset_add,
			R.layout.dialog_pref_stringset_edit, R.string.title_add_stringset,
			R.string.title_edit_stringset, R.drawable.card_redborder), UNSUPPORTED(
			0, 0, 0, 0, R.drawable.card_blueborder);

	private int mDialogLayoutAdd;
	private int mDialogLayoutEdit;
	private int mDialogTitleAdd;
	private int mDialogTitleEdit;
	private int mCardBackground;

	private PreferenceType(int dialogLayoutAdd, int dialogLayoutEdit,
			int dialogTitleAdd, int dialogTitleEdit, int cardBackground) {
		this.mDialogLayoutAdd = dialogLayoutAdd;
		this.mDialogLayoutEdit = dialogLayoutEdit;
		this.mDialogTitleAdd = dialogTitleAdd;
		this.mDialogTitleEdit = dialogTitleEdit;
		this.mCardBackground = cardBackground;
	}

	public static PreferenceType fromObject(Object obj) {
		if (obj instanceof String) {
			return STRING;
		} else if (obj instanceof Integer) {
			return INT;
		} else if (obj instanceof Long) {
			return LONG;
		} else if (obj instanceof Float) {
			return FLOAT;
		} else if (obj instanceof Boolean) {
			return BOOLEAN;
		} else if (obj instanceof Set<?>) {
			return STRINGSET;
		}
		return UNSUPPORTED;
	}

	public static int getDialogLayout(Object obj) {
		return fromObject(obj).getCardBackground();
	}

	public int getDialogLayout(boolean editMode) {
		return editMode ? mDialogLayoutEdit : mDialogLayoutAdd;
	}

	public int getCardBackground() {
		return mCardBackground;
	}

	public int getDialogTitleAdd() {
		return mDialogTitleAdd;
	}

	public int getDialogTitleEdit() {
		return mDialogTitleEdit;
	}
}
{'fraction_non_alphanumeric': 0.08751112429546129, 'fraction_numerical': 0.0035597745476119848, 'mean_word_length': 4.926186291739895, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4234098', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1074, 'n_words': 263}