Time for action – using null progress monitors and sub monitors
When a method uses progress monitors extensively, it is inelegant to keep checking whether the monitor is null
or not. Instead, the progress monitor can be replaced with a NullProgressMonitor
, which acts as a no-op for all monitor calls.
- Update the
checkDozen
to use aNullProgressMonitor
ifnull
is passed:private void checkDozen(IProgressMonitor monitor) { if (monitor == null) monitor = new NullProgressMonitor();
This allows the remainder of the method to run without modification and saves any
NullPointerException
errors that may result. - A similar result to both the
NullProgressMonitor
and aSubProgressMonitor
with a wrapper/factory class calledSubMonitor
. This provides factory methods ...
Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.