{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/47955277","id":47955277,"diff_hunk":"@@ -243,15 +246,30 @@ public String toString() {\n      */\r\n     @Override\r\n     public void stateChanged(Item item, State oldState, State newState) {\r\n-        setState(function.calculate(members));\r\n+        setStateWithouEvent(function.calculate(members));\r\n+        sendGroupStateChangedEvent(item.getName(), this.state, oldGroupState);\r\n     }\r\n-\r\n+    \r\n     /**\r\n      * @{inheritDoc\r\n      */\r\n     @Override\r\n     public void stateUpdated(Item item, State state) {\r\n-        setState(function.calculate(members));\r\n+        setStateWithouEvent(function.calculate(members));\r\n+        sendGroupStateChangedEvent(item.getName(), this.state, oldGroupState);\r\n+    }\r\n+    \r\n+    private void setStateWithouEvent(State state) {\r\n+        this.oldGroupState = this.state;\r\n+        this.state = state;\r\n+        notifyListeners(oldGroupState, state);\r\n     }\r\n \r\n+    private void sendGroupStateChangedEvent(String memberName, State newState, State oldState) {\r\n+        if (eventPublisher != null && !oldGroupState.equals(this.state)) {\r","path":"bundles/core/org.eclipse.smarthome.core/src/main/java/org/eclipse/smarthome/core/items/GroupItem.java","position":66,"original_position":66,"commit_id":"331c281d3ab9a859bab96a50edf419961ac2ad79","original_commit_id":"331c281d3ab9a859bab96a50edf419961ac2ad79","user":{"login":"kaikreuzer","id":3244965,"avatar_url":"https://avatars.githubusercontent.com/u/3244965?v=3","gravatar_id":"","url":"https://api.github.com/users/kaikreuzer","html_url":"https://github.com/kaikreuzer","followers_url":"https://api.github.com/users/kaikreuzer/followers","following_url":"https://api.github.com/users/kaikreuzer/following{/other_user}","gists_url":"https://api.github.com/users/kaikreuzer/gists{/gist_id}","starred_url":"https://api.github.com/users/kaikreuzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaikreuzer/subscriptions","organizations_url":"https://api.github.com/users/kaikreuzer/orgs","repos_url":"https://api.github.com/users/kaikreuzer/repos","events_url":"https://api.github.com/users/kaikreuzer/events{/privacy}","received_events_url":"https://api.github.com/users/kaikreuzer/received_events","type":"User","site_admin":false},"body":"Can't you use the oldState instead of the oldGroupState and newState instead of this.state here? Would be much nicer to refer to the passed parameters than to instance variables.","created_at":"2015-12-17T20:15:39Z","updated_at":"2015-12-17T20:15:39Z","html_url":"https://github.com/eclipse/smarthome/pull/679#discussion_r47955277","pull_request_url":"https://api.github.com/repos/eclipse/smarthome/pulls/679","_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/47955277"},"html":{"href":"https://github.com/eclipse/smarthome/pull/679#discussion_r47955277"},"pull_request":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/679"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/679","id":52975342,"html_url":"https://github.com/eclipse/smarthome/pull/679","diff_url":"https://github.com/eclipse/smarthome/pull/679.diff","patch_url":"https://github.com/eclipse/smarthome/pull/679.patch","issue_url":"https://api.github.com/repos/eclipse/smarthome/issues/679","number":679,"state":"open","locked":false,"title":"Add GroupItemStateChangeEvent #596","user":{"login":"chriskn","id":1077869,"avatar_url":"https://avatars.githubusercontent.com/u/1077869?v=3","gravatar_id":"","url":"https://api.github.com/users/chriskn","html_url":"https://github.com/chriskn","followers_url":"https://api.github.com/users/chriskn/followers","following_url":"https://api.github.com/users/chriskn/following{/other_user}","gists_url":"https://api.github.com/users/chriskn/gists{/gist_id}","starred_url":"https://api.github.com/users/chriskn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriskn/subscriptions","organizations_url":"https://api.github.com/users/chriskn/orgs","repos_url":"https://api.github.com/users/chriskn/repos","events_url":"https://api.github.com/users/chriskn/events{/privacy}","received_events_url":"https://api.github.com/users/chriskn/received_events","type":"User","site_admin":false},"body":"Assertions:\r\nIf a member of a group is changed then notify the observers of the member as well as the observers of the group about the changes.\r\nIf a member is added or removed from a group then notify the observers of the group about the added or removed member.\r\nObservers of the group are informed about the name of the changed, added or removed member.\r\nIf one member is added or removed then one group change is fired.\r\nIf one member changes two changes are fired: one change for the member itself and one for the group.\r\n\r\nImplementation:\r\nGroupItems hold a State of type GroupType which contains the name of the added, removed or changed member and the type of the change as enumeration constant of type GroupChange (ADDED, REMOVED, CHANGED)\r\nIf a member is added, removed or changed the group notifies its observers about the changes. Therefore the method notifyObservers of class GenericItem is used. In order to use this method the visibility was changed from private to protected.\r\nExtended the GroupItemTest to test the notification of observers.\r\n\r\nBug: Add GroupItemStateChangeEvent #596\r\nSigned-off-by: Christoph Knauf  <christoph.knauf@itemis.de>","created_at":"2015-12-08T12:40:46Z","updated_at":"2015-12-17T20:15:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3cda0c794865953df9c3806913dd72344955251f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/smarthome/pulls/679/commits","review_comments_url":"https://api.github.com/repos/eclipse/smarthome/pulls/679/comments","review_comment_url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/smarthome/issues/679/comments","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/331c281d3ab9a859bab96a50edf419961ac2ad79","head":{"label":"chriskn:BUG_596","ref":"BUG_596","sha":"331c281d3ab9a859bab96a50edf419961ac2ad79","user":{"login":"chriskn","id":1077869,"avatar_url":"https://avatars.githubusercontent.com/u/1077869?v=3","gravatar_id":"","url":"https://api.github.com/users/chriskn","html_url":"https://github.com/chriskn","followers_url":"https://api.github.com/users/chriskn/followers","following_url":"https://api.github.com/users/chriskn/following{/other_user}","gists_url":"https://api.github.com/users/chriskn/gists{/gist_id}","starred_url":"https://api.github.com/users/chriskn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriskn/subscriptions","organizations_url":"https://api.github.com/users/chriskn/orgs","repos_url":"https://api.github.com/users/chriskn/repos","events_url":"https://api.github.com/users/chriskn/events{/privacy}","received_events_url":"https://api.github.com/users/chriskn/received_events","type":"User","site_admin":false},"repo":{"id":46263479,"name":"smarthome","full_name":"chriskn/smarthome","owner":{"login":"chriskn","id":1077869,"avatar_url":"https://avatars.githubusercontent.com/u/1077869?v=3","gravatar_id":"","url":"https://api.github.com/users/chriskn","html_url":"https://github.com/chriskn","followers_url":"https://api.github.com/users/chriskn/followers","following_url":"https://api.github.com/users/chriskn/following{/other_user}","gists_url":"https://api.github.com/users/chriskn/gists{/gist_id}","starred_url":"https://api.github.com/users/chriskn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriskn/subscriptions","organizations_url":"https://api.github.com/users/chriskn/orgs","repos_url":"https://api.github.com/users/chriskn/repos","events_url":"https://api.github.com/users/chriskn/events{/privacy}","received_events_url":"https://api.github.com/users/chriskn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chriskn/smarthome","description":"Eclipse SmartHome project","fork":true,"url":"https://api.github.com/repos/chriskn/smarthome","forks_url":"https://api.github.com/repos/chriskn/smarthome/forks","keys_url":"https://api.github.com/repos/chriskn/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chriskn/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chriskn/smarthome/teams","hooks_url":"https://api.github.com/repos/chriskn/smarthome/hooks","issue_events_url":"https://api.github.com/repos/chriskn/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/chriskn/smarthome/events","assignees_url":"https://api.github.com/repos/chriskn/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/chriskn/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/chriskn/smarthome/tags","blobs_url":"https://api.github.com/repos/chriskn/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chriskn/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chriskn/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/chriskn/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chriskn/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/chriskn/smarthome/languages","stargazers_url":"https://api.github.com/repos/chriskn/smarthome/stargazers","contributors_url":"https://api.github.com/repos/chriskn/smarthome/contributors","subscribers_url":"https://api.github.com/repos/chriskn/smarthome/subscribers","subscription_url":"https://api.github.com/repos/chriskn/smarthome/subscription","commits_url":"https://api.github.com/repos/chriskn/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/chriskn/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/chriskn/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/chriskn/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/chriskn/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/chriskn/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chriskn/smarthome/merges","archive_url":"https://api.github.com/repos/chriskn/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chriskn/smarthome/downloads","issues_url":"https://api.github.com/repos/chriskn/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/chriskn/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/chriskn/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/chriskn/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chriskn/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/chriskn/smarthome/releases{/id}","created_at":"2015-11-16T09:04:25Z","updated_at":"2015-11-16T09:04:30Z","pushed_at":"2015-12-17T15:07:51Z","git_url":"git://github.com/chriskn/smarthome.git","ssh_url":"git@github.com:chriskn/smarthome.git","clone_url":"https://github.com/chriskn/smarthome.git","svn_url":"https://github.com/chriskn/smarthome","homepage":null,"size":14769,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"431beda7d1b1b07d5af1b570c79a7a55a1bdd434","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":15778981,"name":"smarthome","full_name":"eclipse/smarthome","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/smarthome","description":"Eclipse SmartHome project","fork":false,"url":"https://api.github.com/repos/eclipse/smarthome","forks_url":"https://api.github.com/repos/eclipse/smarthome/forks","keys_url":"https://api.github.com/repos/eclipse/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/smarthome/teams","hooks_url":"https://api.github.com/repos/eclipse/smarthome/hooks","issue_events_url":"https://api.github.com/repos/eclipse/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/smarthome/events","assignees_url":"https://api.github.com/repos/eclipse/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/smarthome/tags","blobs_url":"https://api.github.com/repos/eclipse/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/smarthome/languages","stargazers_url":"https://api.github.com/repos/eclipse/smarthome/stargazers","contributors_url":"https://api.github.com/repos/eclipse/smarthome/contributors","subscribers_url":"https://api.github.com/repos/eclipse/smarthome/subscribers","subscription_url":"https://api.github.com/repos/eclipse/smarthome/subscription","commits_url":"https://api.github.com/repos/eclipse/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/smarthome/merges","archive_url":"https://api.github.com/repos/eclipse/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/smarthome/downloads","issues_url":"https://api.github.com/repos/eclipse/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/smarthome/releases{/id}","created_at":"2014-01-09T20:47:19Z","updated_at":"2015-12-17T01:56:14Z","pushed_at":"2015-12-17T15:16:08Z","git_url":"git://github.com/eclipse/smarthome.git","ssh_url":"git@github.com:eclipse/smarthome.git","clone_url":"https://github.com/eclipse/smarthome.git","svn_url":"https://github.com/eclipse/smarthome","homepage":null,"size":20315,"stargazers_count":214,"watchers_count":214,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":211,"mirror_url":null,"open_issues_count":129,"forks":211,"open_issues":129,"watchers":214,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/679"},"html":{"href":"https://github.com/eclipse/smarthome/pull/679"},"issue":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/679"},"comments":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/679/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/679/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/679/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/smarthome/statuses/331c281d3ab9a859bab96a50edf419961ac2ad79"}}}}