public void addListener(U type,T listener){
  List<T> newlisteners=new ArrayList<T>();
  if (listeners != null)   newlisteners.addAll(listeners);
  newlisteners.add(listener);
  List<T> terminals=new ArrayList<T>();
  for (  T i : newlisteners) {
    boolean isterm=true;
    for (    T j : newlisteners) {
      if (ispre(type,i,j)) {
        isterm=false;
        break;
      }
    }
    if (isterm) {
      terminals.add(i);
    }
  }
  if (terminals.size() == 0) {
    logger.error("No listener dependency solution: " + "No listeners without incoming dependencies");
    listeners=newlisteners;
    return;
  }
  HashSet<T> visited=new HashSet<T>();
  List<T> ordering=new ArrayList<T>();
  for (  T term : terminals) {
    visit(newlisteners,type,visited,ordering,term);
  }
  listeners=ordering;
}

public void addListener ( U type , T listener ) { List < T > newlisteners = new ArrayList < T > ( ) ; if ( listeners != null ) newlisteners . addAll ( listeners ) ; newlisteners . add ( listener ) ; List < T > terminals = new ArrayList < T > ( ) ; for ( T i : newlisteners ) { boolean isterm = true ; for ( T j : newlisteners ) { if ( ispre ( type , i , j ) ) { isterm = false ; break ; } } if ( isterm ) { terminals . add ( i ) ; } } if ( terminals . size ( ) == 0 ) { logger . error ( "No listener dependency solution: " + "No listeners without incoming dependencies" ) ; listeners = newlisteners ; return ; } HashSet < T > visited = new HashSet < T > ( ) ; List < T > ordering = new ArrayList < T > ( ) ; for ( T term : terminals ) { visit ( newlisteners , type , visited , ordering , term ) ; } listeners = ordering ; }
add a listener to the list of listeners
