Gender.java

  1. /*
  2.  * Copyright (C) 2022-2023 Dipl.-Inform. Kai Hofmann. All rights reserved!
  3.  */
  4. package de.powerstat.validation.values;


  5. import de.powerstat.validation.interfaces.IValueObject;


  6. /**
  7.  * Gender/Sex.
  8.  *
  9.  * This is my own derivation of the following website:
  10.  * https://at.wikimannia.org/60_Geschlechtsidentit%C3%A4ten
  11.  * From my point of view trans-gender is not a gender - it is a change of the gender over time.
  12.  * For example when someone is born as male he will become a female after a transformation.
  13.  * During the transformation BOTH or VARIABLE might be used.
  14.  * This will be handled in the Person class by a history of the gender.
  15.  *
  16.  * @see <a href="https://at.wikimannia.org/60_Geschlechtsidentitäten">Geschlechtsidentitäten</a>
  17.  *
  18.  * Not DSGVO relevant.
  19.  */
  20. public enum Gender implements IValueObject
  21.  {
  22.   /**
  23.    * Unknown/undefined gender.
  24.    */
  25.   UNKNOWN(0),

  26.   /**
  27.    * Female.
  28.    */
  29.   FEMALE(1),

  30.   /**
  31.    * Male.
  32.    */
  33.   MALE(2),

  34.   /**
  35.    * Both female and male at the same time.
  36.    */
  37.   BOTH(3),

  38.   /**
  39.    * Variable, female today, male tomorrow for example (not trans).
  40.    */
  41.   VARIABLE(4),

  42.   /**
  43.    * Without a gender/sex.
  44.    */
  45.   NEUTRAL(5),

  46.   /**
  47.    * Other not here named gender.
  48.    */
  49.   OTHER(6);


  50.   /**
  51.    * Action number.
  52.    */
  53.   private final int action;


  54.   /**
  55.    * Ordinal constructor.
  56.    *
  57.    * @param action Action number
  58.    */
  59.   Gender(final int action)
  60.    {
  61.     this.action = action;
  62.    }


  63.   /**
  64.    * Gender factory.
  65.    *
  66.    * @param value Gender name string
  67.    * @return Gender object
  68.    */
  69.   public static Gender of(final String value)
  70.    {
  71.     return Gender.valueOf(value);
  72.    }


  73.   /**
  74.    * Get action number.
  75.    *
  76.    * @return Action number
  77.    */
  78.   public int getAction()
  79.    {
  80.     return this.action;
  81.    }


  82.   /**
  83.    * Returns the value of this Gender as a string.
  84.    *
  85.    * @return The text value represented by this object after conversion to type string.
  86.    */
  87.   @Override
  88.   public String stringValue()
  89.    {
  90.     return this.name();
  91.    }

  92.  }