private Set < IWatchedCondition > copyConditions ( ) { Set < IWatchedCondition > copiedConditions = null ; // Copy the current Conditions ... synchronized ( conditions ) { Set < IObjectReference < IWatchedCondition >> copiedObjref = new HashSet < IObjectReference < IWatchedCondition > > ( this . conditions ) ; copiedConditions = new HashSet < IWatchedCondition > ( this . conditions . size ( ) ) ; this . conditions . clear ( ) ; IWatchedCondition cond = null ; for ( Iterator < IObjectReference < IWatchedCondition > > iterator = copiedObjref . iterator ( ) ; iterator . hasNext ( ) ; ) { IObjectReference < IWatchedCondition > objRef = iterator . next ( ) ; cond = objRef . get ( ) ; if ( ! objRef . isStale ( ) && cond != null && ! cond . isUseless ( ) ) { copiedConditions . add ( cond ) ; this . conditions . add ( objRef ) ; } } } return copiedConditions ; }
copies the current set of conditions and cleans up the current set of conditions