Optional.ofNullable should only be used with non-null arguments. As primitive types can not hold a null-value, it makes sense to use Optional.of instead.
The rule should validate that the argument is not a primitive type or a method returning a primitive type.
Noncompliant Code Example
Optional.ofNullable(getaLong()).ifPresent(System.out::println);
Compliant Solution
Optional.of(getaLong()).ifPresent(System.out::println);