@SuppressWarnings("unchecked") public <T extends Element>T build(){
  if (level != 0 && elements.size() != 1) {
    throw new IllegalStateException(logId() + "Unbalanced element hierarchy. Elements stack: " + dumpElements());
  }
  return (T)elements.pop().element;
}

@ SuppressWarnings ( "unchecked" ) public < T extends Element > T build ( ) { if ( level != 0 && elements . size ( ) != 1 ) { throw new IllegalStateException ( logId ( ) + "Unbalanced element hierarchy. Elements stack: " + dumpElements ( ) ) ; } return ( T ) elements . pop ( ) . element ; }
builds the element hierarchy and returns the top level element casted to the specified element type .
