package net.pokeranalytics.android.model.interfaces

import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.view.RowRepresentable

/**
 * An interface to grouped object which are managed by the database
 */
interface Manageable : Savable, Deletable, Identifiable

/**
 * An interface associate a unique identifier to an object
 */
interface Identifiable {

	/**
	 * A unique identifier getter
	 */
	var id: String
}

/**
 * An interface to easily handle the validity of any object we want to save
 */
interface Savable {
	/**
	 * A method to define if an object is safe for saving in database
	 */
	fun isValidForSave(): Boolean {
		//TODO should be by default to false
		return true
	}

	/**
	 * A method to get the reason why the object can't be saved
	 */
	fun getFailedSaveMessage(): Int {
		return R.string.none
	}

	/**
	 * a method to handle the modification of the object.
	 * Through [RowRepresentable] the object is able to update the right variable with the new value.
	 */
	fun updateValue(value: Any?, row: RowRepresentable)
}


/**
 * An interface to easily handle the validity of any object we want to delete
 */
interface Deletable {

	/**
	 * A method to define if an object is safe for deletion in database
	 */
	fun isValidForDelete(): Boolean {
		return true
	}

	/**
	 * A method to get the reason why the object can't be deleted
	 */
	fun getFailedDeleteMessage(): Int {
		return R.string.none
	}
}