public class CollectionToArrayHeuristics extends Object
Collection.toArray()
.
The semantics of Collection.toArray(T[])
cannot be
captured by the nullness type system syntax. The nullness type of the returned array depends on
the size of the passed parameter. In particular, the returned array component is of type
@NonNull
if the following conditions hold:
NonNull
, and
c.toArray(new String[] { })
,
c.toArray(new String[0])
, or
c.toArray(new String[c.size()])
Constructor and Description |
---|
CollectionToArrayHeuristics(ProcessingEnvironment env,
NullnessAnnotatedTypeFactory factory) |
Modifier and Type | Method and Description |
---|---|
void |
handle(MethodInvocationTree tree,
AnnotatedTypeMirror.AnnotatedExecutableType method)
If the method invocation is a call to
toArray , then it manipulates the returned type
of method arg to contain the appropriate nullness. |
public CollectionToArrayHeuristics(ProcessingEnvironment env, NullnessAnnotatedTypeFactory factory)
public void handle(MethodInvocationTree tree, AnnotatedTypeMirror.AnnotatedExecutableType method)
toArray
, then it manipulates the returned type
of method
arg to contain the appropriate nullness. Otherwise, it does nothing.tree
- method invocation treemethod
- invoked method type