All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.unibo.alchemist.model.cognitive.impact.individual.Gender.kt Maven / Gradle / Ivy

There is a newer version: 35.0.0
Show newest version
package it.unibo.alchemist.model.cognitive.impact.individual

/**
 * An enum representing the different genders.
 */
enum class Gender : Characteristic {

    /**
     * Male.
     */
    MALE,

    /**
     * Female.
     */
    FEMALE,
    ;

    /**
     * Factories for [Gender].
     */
    companion object {
        private const val MALE_KEYWORD = "male"
        private const val FEMALE_KEYWORD = "female"

        /**
         * Returns the corresponding gender in this enum given a string resembling it.
         *
         * @param gender
         *          the gender as a string.
         */
        fun fromString(gender: String): Gender = when {
            gender.equals(MALE_KEYWORD, ignoreCase = true) -> MALE
            gender.equals(FEMALE_KEYWORD, ignoreCase = true) -> FEMALE
            else -> throw IllegalArgumentException("$gender is not a valid gender")
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy