/* * Copyright (C) 2012 Joe AmRhein * * 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 com.arconus.dicecommander.model.entities.character; import com.arconus.dicecommander.R; import com.arconus.dicecommander.utilities.IResourceAndDBPair; public enum Defenses implements IResourceAndDBPair { AC(0, R.string.defense_ac, R.string.defense_ac), FORTITUDE(1, R.string.defense_fort, R.string.defense_fort_short), REFLEX(2, R.string.defense_ref, R.string.defense_ref_short), WILL(3, R.string.defense_will, R.string.defense_will_short); private int dbID; private int resID; private int resIDShort; private static final Defenses[] values = values(); private Defenses(int dbID, int resID, int resIDShort) { this.dbID = dbID; this.resID = resID; this.resIDShort = resIDShort; } //used by content provider to store enum value in database public int getDatabaseID() { return dbID; } //used to reference the string resource associated with this enum. Allows for //localization of strings public int getResourceID() { return resID; } public int getResourceIDShort() { return resIDShort; } public static Defenses parseInt(int index) { if (index >= values.length || index < 0) { return null; } return values[index]; } }