public void setItemBand( final ItemBand itemBand ) { if ( itemBand == null ) { throw new NullPointerException( "The itemBand must not be null" ); } validateLooping( itemBand ); if ( unregisterParent( itemBand ) ) { return; } final ItemBand oldElement = this.itemBand; this.itemBand.setParent( null ); this.itemBand = itemBand; this.itemBand.setParent( this ); notifyNodeChildRemoved( oldElement ); notifyNodeChildAdded( this.itemBand ); }
@Test public void testSetItemBand() { ItemBand itemBand = mock( ItemBand.class ); body.setItemBand( itemBand ); assertThat( body.getItemBand(), is( equalTo( itemBand ) ) ); assertThat( (GroupDataBody) body.getItemBand().getParentSection(), is( equalTo( body ) ) ); ItemBand band = new ItemBand(); band.setParent( body ); body.setItemBand( band ); assertThat( body.getItemBand(), is( equalTo( itemBand ) ) ); }
protected void removeElement( final Element element ) { if ( element == null ) { throw new NullPointerException(); } if ( element == itemBand ) { this.itemBand.setParent( null ); this.itemBand = new ItemBand(); this.itemBand.setParent( this ); notifyNodeChildRemoved( element ); notifyNodeChildAdded( this.itemBand ); } else if ( element == noDataBand ) { this.noDataBand.setParent( null ); this.noDataBand = new NoDataBand(); this.noDataBand.setParent( this ); notifyNodeChildRemoved( element ); notifyNodeChildAdded( this.noDataBand ); } else if ( element == detailsHeader ) { this.detailsHeader.setParent( null ); this.detailsHeader = new DetailsHeader(); this.detailsHeader.setParent( this ); notifyNodeChildRemoved( element ); notifyNodeChildAdded( this.detailsHeader ); } else if ( element == detailsFooter ) { this.detailsFooter.setParent( null ); this.detailsFooter = new DetailsFooter(); this.detailsFooter.setParent( this ); notifyNodeChildRemoved( element ); notifyNodeChildAdded( this.detailsFooter ); } }