Another mostly unnoticed but powerful feature of NetBeans is the possibility of creating custom hints.
Custom hints (a.k.a custom inspections or quickfixes in other IDEs) are available since NetBeans 7.1. They match patterns in Java code and can provide a transformation. This enables you to create small refactorings based on the AST without coding. A typical usecase is the type-safe migration of API – instead of the error-prone plain text-based “search and replace” approach.
You can create your own hint in a special DSL as described in ,,. Geertjan already blogged several times about this topic at  and . Yes, the UI for creating/enabling the hints is not very intuitive, but it works.
The best thing is the integration in the editor:
Your custom hints
- are available in the Java editor like the “standard” hints
- can be applied to a file/package/project or even all opened projects. It includes also a changes-preview. This is pretty useful to do apply transformations in a batch.
Here some very basic examples:
<!description="Convert to assertTrue/assertFalse">
org.junit.Assert.assertEquals($msg, true, $any)
=> org.junit.Assert.assertTrue($msg, $any)
org.junit.Assert.assertEquals($msg, false, $any)
=> org.junit.Assert.assertFalse($msg, $any)
<!description="Remove dead if-branch">
<!description="Add extra parenthesis">
$a && $b
($a) && ($b)
$a || $b
($a) || ($b)
$a & $b
$b & $a
$a && $b
$b && $a
$a || $b
$b || $a
<!description="Flip < >">
$a < $b =>
$b > $a
$a > $b
$b < $a
<!description="JUL to SLF4J">
$jul.info($msg) :: $jul instanceof java.util.logging.Logger && $msg instanceof java.lang.String
Those patterns can also be used to code more advanced hints  .
Give it a try and share your patterns! Which selfmade hints do you use on a regular basis?
FYI: Intellj IDEA provides a similar feature called “structural replace” 
Update from 2015/02: Added new links