public static < R extends Resource , X > ResourcePredicate < R > distinctFilter ( FunctionWithThrowable < R , X , IOException > function ) { final Map < X , Boolean > seen = Maps . newConcurrentMap ( ) ; return resource -> seen . putIfAbsent ( function . apply ( resource ) , Boolean . TRUE ) == null ; }
A predicate to filter out already seen resources by function .