I don't have an answer for you, but I am really curious how you are using your two-dimensional key-space. Isn't a map usually enough?
I think this question is better suited for here than StackOverflow because it's more about opinion and best practice than a black-and-white facts, but apologies if it's in the wrong place.I have a settings class that is backed by two Table<String,String,Object> instances for 'settings' and 'defaults'. When retrieving a setting, the value at the given String keys in 'settings' is returned. If it's unset, the value at the same place in 'defaults' is returned. If that too is absent, an exception is thrown.In this arrangement, a null value has a single defined meaning, that a key has been set but the value is deliberately empty. Null never means that the key is not set. However, because HashBasedTable doesn't support null values, I'm looking at implementing Optional<Object> for the value type instead.I have two options, and I'm wondering which one would be the better practice:1. Have the settings class get and set Optional<Object> instances directly without modification. This would require classes making use of the settings class to wrap and unwrap values themselves first.2. Have the settings class get and set Objects, and handle the wrapping into Optional<Object> internally. ie. null would be converted to Optional.absent() and vice versa.If null was ambiguous in this case as it is in Map (ie. is null intentional or does it mean the key doesn't exist?) then the first choice would be obvious, but because null has a single fixed meaning in this case, I'm not sure if exposing the Optional to the rest of the application would be better practice, or having the settings class handle it internally.Thanks,Mike--
--
guava-...@googlegroups.com
Project site: http://guava-libraries.googlecode.com
This group: http://groups.google.com/group/guava-discuss
This list is for general discussion.
To report an issue: http://code.google.com/p/guava-libraries/issues/entry
To get help: http://stackoverflow.com/questions/ask (use the tag "guava")
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.