{"action":"opened","issue":{"url":"https://api.github.com/repos/Whaka-project/whakamatautau-util/issues/91","labels_url":"https://api.github.com/repos/Whaka-project/whakamatautau-util/issues/91/labels{/name}","comments_url":"https://api.github.com/repos/Whaka-project/whakamatautau-util/issues/91/comments","events_url":"https://api.github.com/repos/Whaka-project/whakamatautau-util/issues/91/events","html_url":"https://github.com/Whaka-project/whakamatautau-util/issues/91","id":113068552,"number":91,"title":"[Utils] Implement stream method filterByClass","user":{"login":"vantuz-subhuman","id":5585355,"avatar_url":"https://avatars.githubusercontent.com/u/5585355?v=3","gravatar_id":"","url":"https://api.github.com/users/vantuz-subhuman","html_url":"https://github.com/vantuz-subhuman","followers_url":"https://api.github.com/users/vantuz-subhuman/followers","following_url":"https://api.github.com/users/vantuz-subhuman/following{/other_user}","gists_url":"https://api.github.com/users/vantuz-subhuman/gists{/gist_id}","starred_url":"https://api.github.com/users/vantuz-subhuman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vantuz-subhuman/subscriptions","organizations_url":"https://api.github.com/users/vantuz-subhuman/orgs","repos_url":"https://api.github.com/users/vantuz-subhuman/repos","events_url":"https://api.github.com/users/vantuz-subhuman/events{/privacy}","received_events_url":"https://api.github.com/users/vantuz-subhuman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Whaka-project/whakamatautau-util/labels/[type]%20feature","name":"[type] feature","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/Whaka-project/whakamatautau-util/milestones/3","html_url":"https://github.com/Whaka-project/whakamatautau-util/milestones/Release:%200.0.9","labels_url":"https://api.github.com/repos/Whaka-project/whakamatautau-util/milestones/3/labels","id":1314593,"number":3,"title":"Release: 0.0.9","description":"Due date it extremely optional.\r\nIt's just that there aren't much features in the plans.","creator":{"login":"vantuz-subhuman","id":5585355,"avatar_url":"https://avatars.githubusercontent.com/u/5585355?v=3","gravatar_id":"","url":"https://api.github.com/users/vantuz-subhuman","html_url":"https://github.com/vantuz-subhuman","followers_url":"https://api.github.com/users/vantuz-subhuman/followers","following_url":"https://api.github.com/users/vantuz-subhuman/following{/other_user}","gists_url":"https://api.github.com/users/vantuz-subhuman/gists{/gist_id}","starred_url":"https://api.github.com/users/vantuz-subhuman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vantuz-subhuman/subscriptions","organizations_url":"https://api.github.com/users/vantuz-subhuman/orgs","repos_url":"https://api.github.com/users/vantuz-subhuman/repos","events_url":"https://api.github.com/users/vantuz-subhuman/events{/privacy}","received_events_url":"https://api.github.com/users/vantuz-subhuman/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2015-09-19T15:19:56Z","updated_at":"2015-10-23T17:54:46Z","due_on":"2015-12-30T21:00:00Z","closed_at":null},"comments":0,"created_at":"2015-10-23T17:54:46Z","updated_at":"2015-10-23T17:54:46Z","closed_at":null,"body":"Relatively often use keys is when you have a stream of some super type and you need to filter only those items that are instances of some specific subtype and then continue to work with these instances. With default stream it takes two boilerplate operations:\r\n\r\n```\r\nList<Number> numbers == ...\r\nnumbers.stream()\r\n    .filter(Double.class::isInstance)\r\n    .map(Double.class::cast);\r\n```\r\n\r\n### UberStream\r\n`UberStream` should have method `filterByClass(Class)` that will perform both those operations and return `UberStream` of new type:\r\n\r\n```\r\nList<Number> numbers == ...\r\nDouble d = stream(numbers)\r\n    .filterByClass(Double.class)\r\n    .findFirst().orElse(null);\r\n```\r\n\r\nSo method should look something like this:\r\n`public <R extends T> UberStream<R> filterByClass(Class<R> filterClass);`\r\n\r\n### MapStream\r\n`MapStream` should also have methods like:\r\n`public <R extends K> MapStream<R,V> filterKeysByClass(Class<R> filterClass);`\r\n`public <R extends V> MapStream<K,R> filterValuesByClass(Class<R> filterClass);`"}}