public Collection < Response > findResponses ( SearchCriteria criteria , Collection < Response > responses ) { if ( criteria == null ) { throw new IllegalArgumentException ( "criteria must be non-null" ) ; } Collection < Response > matches = new ArrayList < Response > ( ) ; User user = criteria . getUser ( ) ; Collection < String > detectionSystemIds = criteria . getDetectionSystemIds ( ) ; DateTime earliest = DateUtils . fromString ( criteria . getEarliest ( ) ) ; for ( Response response : responses ) { //check user match if user specified boolean userMatch = ( user != null ) ? user . equals ( response . getUser ( ) ) : true ; //check detection system match if detection systems specified boolean detectionSystemMatch = ( detectionSystemIds != null && detectionSystemIds . size ( ) > 0 ) ? detectionSystemIds . contains ( response . getDetectionSystem ( ) . getDetectionSystemId ( ) ) : true ; DateTime responseTimestamp = DateUtils . fromString ( response . getTimestamp ( ) ) ; boolean earliestMatch = ( earliest != null ) ? ( earliest . isBefore ( responseTimestamp ) || earliest . isEqual ( responseTimestamp ) ) : true ; if ( userMatch && detectionSystemMatch && earliestMatch ) { matches . add ( response ) ; } } return matches ; }
Finder for responses in the ResponseStore