Skip to content

Using NullableJ

Nawa Manusitthipol edited this page Feb 4, 2018 · 3 revisions

The example code above makes use of @ExtensionMethod. So for the above code to compile, the following annotation must be added to the class the above code it on using.

import nawaman.nullable.NullableJ;

...

@ExtensionMethod({ NullableJ.class })

@ExtensionMethod do have some limitations, see the "Limitations" section in my article for more information. If you do not like using @ExtensionMethod, use can straight out calling those method from NullableJ

import nawaman.nullable.NullableJ;

...

return NullableJ._whenMatches(string, "^[0-9]+$").map(Integer::parseInt).orElse(-1);

or with static import ...

import static nawaman.nullable.NullableJ._as;

...

return _whenMatches(string, "^[0-9]+$").map(Integer::parseInt).orElse(-1);

See how to setup a Using NullableJ in a Gradle project or Using NullableJ in a in Maven project to use NullableJ.

Clone this wiki locally