@Retention(value=SOURCE) @Target(value=TYPE) public @interface NullKeyAllowed
Set
- or
Map
-like class or interface with a reference key type should allow insertion
and queries of the null
key. If a @KolobokeSet
- or @KolobokeMap
-annotated type is not annotated with @NullKeyAllowed
or
annotated with @NullKeyAllowed(false)
, Koloboke Compile generates an implementation that
throws NullPointerException
on any attempt to insert or query the presence of the null
key in the instance of this implementation. If the implemented type is annotated with
@NullKeyAllowed
or NullKeyAllowed(true)
, Koloboke Compile generates
an implementation that fully allows the null
key (just like HashSet
or HashMap
).
The Koloboke Collections's API counterpart of @NullKeyAllowed
is ObjHashFactory.withNullKeyAllowed(boolean)
configuration. An important difference is that
@NullKeyAllowed
does guarantee that the implementation, generated by Koloboke
Compile, throws NullPointerException
to enforce the null
key disallowance in
runtime, while ObjHashFactory
doesn't guarantee that.
If the annotated type has a numeric primitive key type, Koloboke Compile emits a compilation error and doesn't generate an implementation for the annotated type.
Modifier and Type | Optional Element and Description |
---|---|
boolean |
value
Tells whether a Koloboke Compile-generated implementation of the annotated
Set - or
Map -like class or interface should allow insertion and queries of the null
key. |
public abstract boolean value
Set
- or
Map
-like class or interface should allow insertion and queries of the null
key.
Default value is true
, that allows natural omission of the value specification:
@NullKeyAllowed
is equivalent to @NullKeyAllowed(true)
or
@NullKeyAllowed(value=true)
, but @NullKeyAllowed
is not applied to a class
or interface altogether, Koloboke Compile generates an implementation that disallow
the null
key.
true
if the Koloboke Compile-generated implementation of the annotated type
should allow insertion and queries of the null
key, false
otherwise