/** * Must be called by subclasses to set the final end points of the assembly the subclass represents. * * @param tails of type Pipe */ protected void setTails( Pipe... tails ) { if( this.tails != null ) throw new IllegalStateException( "this method may only be called once" ); this.tails = tails; if( previous == null ) { LOG.warn( "previous pipes not set via setPrevious or constructor on: {}", this ); return; } Set<Pipe> stopSet = new HashSet<Pipe>(); Collections.addAll( stopSet, previous ); setParent( stopSet, tails ); }
private void setParent( Set<Pipe> stopSet, Pipe[] tails ) { if( tails == null ) return; for( Pipe tail : tails ) { if( stopSet.contains( tail ) ) continue; tail.setParent( this ); Pipe[] current; if( tail instanceof SubAssembly ) current = ( (SubAssembly) tail ).previous; else current = tail.getPrevious(); if( current == null && tail instanceof SubAssembly ) LOG.warn( "previous pipes not set via setPrevious or constructor on: {}", tail ); setParent( stopSet, current ); } }