public static SiblingCounter alter ( final SiblingCounter counter , final int delta ) { assert counter != null ; return new SiblingCounter ( ) { @ Override public int countSiblingsNamed ( Name childName ) { int count = counter . countSiblingsNamed ( childName ) + delta ; return count > 0 ? count : 0 ; // never negative } } ; }
Creates a sibling counter that alters another counter by a constant value .