How can I get the size of an Enumeration<String>
without iterate over it?
While debugging I can see the size
of the the enumeration but I can't find a way to get this value.
You can do Collections. list(enumerationObject). size(); to get the number of elements. This creates a list.
An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special '' error value. In theory, an ENUM column can have a maximum of 65,535 distinct values; in practice, the real maximum depends on many factors.
enum is a syntactic sugar that allows for meaningful constants; Enumeration is a class that provides way to go through a collection.
An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week.
The Enumeration
interface does not expose its size, and some (many?) implementations indeed do not have this knowledge. Without any knowledge of the specific implementation, you have no choice but to iterate over it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With