public MessageSet getCachedMessagesWhere ( Predicate < Message > filter ) { synchronized ( messages ) { return messages . values ( ) . stream ( ) . map ( Reference :: get ) . filter ( Objects :: nonNull ) . filter ( filter ) . collect ( Collectors . toCollection ( MessageSetImpl :: new ) ) ; } }
Get messages from the cache that satisfy a given condition .