public List < ISubmission > filter ( List < ISubmission > submissions ) { // // Make a copy of the submissions // List < ISubmission > sortedSubmissions = new ArrayList < ISubmission > ( ) ; sortedSubmissions . addAll ( submissions ) ; // // Sort newest-first // Collections . sort ( sortedSubmissions , new SubmissionComparator ( ) ) ; // // Create the output array // List < ISubmission > filteredSubmissions = new ArrayList < ISubmission > ( ) ; // // Iterate and add // for ( ISubmission submission : sortedSubmissions ) { if ( submission . getAction ( ) != null ) { if ( submission . getAction ( ) . getVerb ( ) != null ) { if ( submission . getAction ( ) . getVerb ( ) . equals ( verb ) ) { if ( ! filteredSubmissions . contains ( submission ) ) { filteredSubmissions . add ( submission ) ; } } } } } return filteredSubmissions ; }
Given a list of submissions return only the submissions that are unique for a given set of resources and actors taking the most recent as being the definitive .