ever debugged through code that processed items of a huge collection?
but you are only interested in the processing of one specific collection?
never mind – there are good news!
Eclipse offers the chance to define conditional breakpoints, that is to specify a condition under which the breakpoint will suspend, if and only if that condition will become true (or alternatively, everytime the condition changes).
what to do
switch to the ‘debug’ perspective and open the view ‘breakpoints’
open the contextmenu of the breakpoint you want to make conditional and select ‘Breakpoint Properties…’
activate the checkbox ‘Enable Condition’.
now you are allowed to type the condition under which circumstances the breakpoint should suspend. you are free to express an arbitrary java expression (in the above mentioned case a boolean expression).
you can refer to any object, which is visible to the point in your source the pointcut is set (ctrl + space will list all referencable objects).
for example, the condition could refer to a property of the longing item of the collection which has an unique value
(like currentItem.getNamedId().equals( “1234567” ) ).
be sure, that the option ‘Suspend when: condition is true’ is activated
suspend policy should be set to ‘Suspend Thread’
The next time you debug through that piece of code, the breakpoint will only suspend, if the specified condition becomes true.