hibernate/hibernate-ogm — pull request #236 by gunnarmorling (2013-10-16 09:41:12+00:00)
Title: OGM-348

Based on top of https://github.com/hibernate/hibernate-ogm/pull/235

This change offers a typed API to retrieve options from an `OptionContainer`:

OptionsContainer options = ...;

//retrieving unique option
ForceExampleOption forceOption = options.getUnique( ForceExampleOption.class );

//retrieving non-unique option
Set queries = options.get( NamedQueryOption.class );

Internally, `OptionContainer` manages two maps (keyed by option type) for unique and non-unique options.

Note that the second commit (https://github.com/gunnarmorling/hibernate-ogm/commit/d6bf1429a530cee3d338c1c45a07c235869ba0dd) which removes `UniqueOption#getOptionIdentifier()` is not strictly required, I've created it as a base for discussion. Previously, the following would have hold true:

//identity solely based on the type
ForceExampleOption.TRUE.equals( ForceExampleOption.FALSE )

This seemed quite irritating to me and also opens the door for subtle issues like this:

//would be true also if actually FALSE was contained
assertThat( optionsContainer ).containsOnly( ForceExampleOption.TRUE );