How to solve this depends on what you want when an illegal symbol is specified, which, in turn, depends on what we say and how the consumption library uses it.
The most sensible thing to do is to throw an IllegalArgumentException , and this is what I suggest you do.
However, this may make sense just return null , even if I strongly recommend against it (you cannot do it directly in the constructor, but you can create a factory method that does this).
Tomas lycken
source share