[infinispan-dev] Making confusion between different remove() APIs
Krzysztof Sobolewski
Krzysztof.Sobolewski at atm.com.pl
Tue Nov 3 09:47:17 EST 2009
Dnia wtorek 03 listopad 2009 o 14:24:35 Sanne Grinovero napisał(a):
> I've been trying different approaches, sorry I couldn't find a nice
> solution.
>
> The only way I see is change all Flag... to an explicit array:
>
> V remove(Object key, Flag... flags);
> would become
>
> V remove(Object key);
> AND
> V remove(Object key, Flag[] flags);
>
> (having both signatures)
> This would force the creation of an array if you want any flag, I
> don't like it much.
> Logging a warning would be way better than doing nothing.
May I drop in two other approaches?
* Rename one of the methods to remove ambiguity altogether.
* Overload like this:
V remove(Object key);
V remove(Object key, Flag flag); // optional, would create collision in
Cache<K, Flag>
V remove(Object key, Flag flagHead, Flag... flagRest); // unweildy
Varargs are too convenient to lose the syntactic benefits, IMO :)
I would prefer the first option, myself. But for consistency's sake it would
require renaming flag-taking variants of all mehods (and possibly other
variants too).
-KS
More information about the infinispan-dev
mailing list