msgpack-java
msgpack-java copied to clipboard
API consistency
When I have a Value
object, e.g. IntegerValue
, how should I get the underlying int out of it?
IntegerValue v = ...;
v.asInt(); // this would look be be correct
now with a BooleanValue
:
BooleanValue v = ...;
v.asBool(); // doesn't exist
v.asBoolean(); // doesn't exist
v.getBoolean(); // this is the one!
OK, so my asInt
must be the wrong method above...
IntegerValue v = ...;
v.getInteger(); // nope, this doesn't exist
v.getInt(); // nope, this doesn't exist
v.asInt(); // this really is the right one
So I am not sure how to get the actual data out of these value objects, as the methods going to get asXXX
or getXXX
? Let's try another type:
FloatValue v = ...;
v.asFloat(); // nope, try again
v.getFloat(); // no dice
v.toFloat(); // that kept you on your toes, didn't it!?
So should I be running with asXXX
, getXXX
, or toXXX
? There doesn't appear to be logic behind this, so is it just a random one of those three depending on what the type is?