[BUGFIX] Follow-Up: Fix major bug in Enumeration::equals + Tests

* Fixed major bug in Enumeration->equals method by
  changing object comparison to loose comparison
* Optimized Enumeration at some places
* Do not throw generic exceptions but specific exceptions
* Add Unit tests
* Move "cast" function from VersionState to Enumeration

Resolves: #52551
Releases: 6.2
Change-Id: Ief64bc08e474c38036d34ed3791c13e39661e9b3
Reviewed-on: https://review.typo3.org/24634
Reviewed-by: Sebastian Fischer
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring