The said method has the following precondition:
Environment.instance().getToolManager().canCreateTool(subtoolType,
optionalMaterial.getClass())
which makes optionalMaterial a required parameter that
may not be null.
Solution: Replace the precondition with :
optionalMaterial != null ?
Environment.instance().getToolManager().canCreateTool(subtoolType,
optionalMaterial.getClass()) :
Environment.instance().getToolManager().canCreateTool(subtoolType)