agrison / jtoml

TOML for Java
MIT License
45 stars 13 forks source link

Getter should return `boolean`, not `Boolean`. #4

Closed adamv closed 11 years ago

adamv commented 11 years ago

Since the Getter throws if the value isn't convertible to a boolean, the interface should return lower-case boolean instead of nullable upper-case Boolean.

agrison commented 11 years ago

Do you want to avoid unboxing or calling manually Boolean.booleanValue() ?

If the parser can't match \w = (true|false) the value isn't stored into the context map, so the call to Toml.getBoolean() will throw an Exception because the key is not there (null is not instance of Boolean).

So yes, it's easy to return the primitive boolean value if found (value is not null), and throw an Exception if not (as it is already the case), but I wonder what would be the advantage of it put aside my first sentence. Could you explain ?

Thank you very much. Alexandre