{"action":"created","comment":{"url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/comments/34267276","id":34267276,"diff_hunk":"@@ -26,48 +26,63 @@\n import java.util.List;\n import java.util.Objects;\n import java.util.StringJoiner;\n+import java.util.stream.Collectors;\n \n /**\n  * This class provides skeletal implementations of common methods for tuples.\n  *\n  * @author Andre Santos <contact.andre.santos@gmail.com>\n+ * @author Benjamim Sonntag <benjamimsonntag@gmail.com>\n  */\n public abstract class AbstractTuple implements Tuple {\n-    // Note that this implementation is not final.\n+    /**\n+     * {@inheritDoc}\n+     */\n     @Override\n     public List<?> asList() {\n         return Collections.unmodifiableList(Arrays.asList(this.toArray()));\n     }\n \n+    /**\n+     * {@inheritDoc}\n+     */\n     @Override\n     public final boolean equals(Object obj) {\n-        if (this == obj) { return true; }\n-        if (!(obj instanceof Tuple)) { return false; }\n-        Tuple t = (Tuple) obj;\n-        if (this.arity() != t.arity()) { return false; }\n-        Object[] a1 = this.toArray();\n-        Object[] a2 = t.toArray();\n-        for (int i = 0; i < this.arity(); ++i) {\n-            if (!Objects.equals(a1[i], a2[i])) { return false; }\n+        if (this == obj) {\n+            return true;\n+        }\n+        else if (!(obj instanceof Tuple)) {\n+            return false;\n+        }\n+        else {\n+            return equalsTuple((Tuple) obj);\n+        }\n+    }\n+\n+    private boolean equalsTuple(Tuple other) {\n+        if (this.arity() != other.arity()) {\n+            return false;\n+        }\n+        else {\n+            return Arrays.equals(this.toArray(), other.toArray());\n         }\n-        return true;\n     }\n \n+    /**\n+     * {@inheritDoc}\n+     */\n     @Override\n     public final int hashCode() {\n-        int hashCode = 1;\n-        for (Object e: this.asList()) {\n-            hashCode = 31 * hashCode + Objects.hashCode(e);\n-        }\n-        return hashCode;\n+        return this.asList().hashCode();\n     }\n \n+    /**\n+     * {@inheritDoc}\n+     */\n     @Override\n     public final String toString() {\n-        StringJoiner joiner = new StringJoiner(\", \", \"(\", \")\");\n-        for (Object e: this.asList()) {\n-            joiner.add(String.valueOf(e));\n-        }\n-        return joiner.toString();\n+        return this.asList().stream()\n+                .map(String::valueOf)\n+                .collect(Collectors.joining(\", \", \"(\", \")\"));","path":"jtuples/src/main/java/org/jtuples/AbstractTuple.java","position":81,"original_position":81,"commit_id":"a361164fa77085261e60748b8dba795b669f2684","original_commit_id":"6b56202957342aa72d30d942e636c53218d36636","user":{"login":"git-afsantos","id":5166824,"avatar_url":"https://avatars.githubusercontent.com/u/5166824?v=3","gravatar_id":"","url":"https://api.github.com/users/git-afsantos","html_url":"https://github.com/git-afsantos","followers_url":"https://api.github.com/users/git-afsantos/followers","following_url":"https://api.github.com/users/git-afsantos/following{/other_user}","gists_url":"https://api.github.com/users/git-afsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/git-afsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-afsantos/subscriptions","organizations_url":"https://api.github.com/users/git-afsantos/orgs","repos_url":"https://api.github.com/users/git-afsantos/repos","events_url":"https://api.github.com/users/git-afsantos/events{/privacy}","received_events_url":"https://api.github.com/users/git-afsantos/received_events","type":"User","site_admin":false},"body":"Leave it as it is. We will go back and optimize if there is any reason to optimize.","created_at":"2015-07-09T15:25:13Z","updated_at":"2015-07-09T15:25:13Z","html_url":"https://github.com/git-afsantos/jTuples/pull/17#discussion_r34267276","pull_request_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/comments/34267276"},"html":{"href":"https://github.com/git-afsantos/jTuples/pull/17#discussion_r34267276"},"pull_request":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/17","id":39587305,"html_url":"https://github.com/git-afsantos/jTuples/pull/17","diff_url":"https://github.com/git-afsantos/jTuples/pull/17.diff","patch_url":"https://github.com/git-afsantos/jTuples/pull/17.patch","issue_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/17","number":17,"state":"open","locked":false,"title":"Improve AbstractTuple class","user":{"login":"bsonntag","id":6205451,"avatar_url":"https://avatars.githubusercontent.com/u/6205451?v=3","gravatar_id":"","url":"https://api.github.com/users/bsonntag","html_url":"https://github.com/bsonntag","followers_url":"https://api.github.com/users/bsonntag/followers","following_url":"https://api.github.com/users/bsonntag/following{/other_user}","gists_url":"https://api.github.com/users/bsonntag/gists{/gist_id}","starred_url":"https://api.github.com/users/bsonntag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsonntag/subscriptions","organizations_url":"https://api.github.com/users/bsonntag/orgs","repos_url":"https://api.github.com/users/bsonntag/repos","events_url":"https://api.github.com/users/bsonntag/events{/privacy}","received_events_url":"https://api.github.com/users/bsonntag/received_events","type":"User","site_admin":false},"body":"This improves the AbstractTuple class by simplifying the method implementations and by adding javadocs with `{@inheritDoc}`.\r\nThis also adds tests for `toString` methods.","created_at":"2015-07-09T14:13:20Z","updated_at":"2015-07-09T15:25:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"21d9cacdf57997fc35e9f6199e772006d8f90fa5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/17/commits","review_comments_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/17/comments","review_comment_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls/comments{/number}","comments_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/17/comments","statuses_url":"https://api.github.com/repos/git-afsantos/jTuples/statuses/a361164fa77085261e60748b8dba795b669f2684","head":{"label":"git-afsantos:bs-improve-abstract-tuple","ref":"bs-improve-abstract-tuple","sha":"a361164fa77085261e60748b8dba795b669f2684","user":{"login":"git-afsantos","id":5166824,"avatar_url":"https://avatars.githubusercontent.com/u/5166824?v=3","gravatar_id":"","url":"https://api.github.com/users/git-afsantos","html_url":"https://github.com/git-afsantos","followers_url":"https://api.github.com/users/git-afsantos/followers","following_url":"https://api.github.com/users/git-afsantos/following{/other_user}","gists_url":"https://api.github.com/users/git-afsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/git-afsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-afsantos/subscriptions","organizations_url":"https://api.github.com/users/git-afsantos/orgs","repos_url":"https://api.github.com/users/git-afsantos/repos","events_url":"https://api.github.com/users/git-afsantos/events{/privacy}","received_events_url":"https://api.github.com/users/git-afsantos/received_events","type":"User","site_admin":false},"repo":{"id":35178869,"name":"jTuples","full_name":"git-afsantos/jTuples","owner":{"login":"git-afsantos","id":5166824,"avatar_url":"https://avatars.githubusercontent.com/u/5166824?v=3","gravatar_id":"","url":"https://api.github.com/users/git-afsantos","html_url":"https://github.com/git-afsantos","followers_url":"https://api.github.com/users/git-afsantos/followers","following_url":"https://api.github.com/users/git-afsantos/following{/other_user}","gists_url":"https://api.github.com/users/git-afsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/git-afsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-afsantos/subscriptions","organizations_url":"https://api.github.com/users/git-afsantos/orgs","repos_url":"https://api.github.com/users/git-afsantos/repos","events_url":"https://api.github.com/users/git-afsantos/events{/privacy}","received_events_url":"https://api.github.com/users/git-afsantos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/git-afsantos/jTuples","description":"Java gets a Pair.","fork":false,"url":"https://api.github.com/repos/git-afsantos/jTuples","forks_url":"https://api.github.com/repos/git-afsantos/jTuples/forks","keys_url":"https://api.github.com/repos/git-afsantos/jTuples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/git-afsantos/jTuples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/git-afsantos/jTuples/teams","hooks_url":"https://api.github.com/repos/git-afsantos/jTuples/hooks","issue_events_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/events{/number}","events_url":"https://api.github.com/repos/git-afsantos/jTuples/events","assignees_url":"https://api.github.com/repos/git-afsantos/jTuples/assignees{/user}","branches_url":"https://api.github.com/repos/git-afsantos/jTuples/branches{/branch}","tags_url":"https://api.github.com/repos/git-afsantos/jTuples/tags","blobs_url":"https://api.github.com/repos/git-afsantos/jTuples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/git-afsantos/jTuples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/git-afsantos/jTuples/git/refs{/sha}","trees_url":"https://api.github.com/repos/git-afsantos/jTuples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/git-afsantos/jTuples/statuses/{sha}","languages_url":"https://api.github.com/repos/git-afsantos/jTuples/languages","stargazers_url":"https://api.github.com/repos/git-afsantos/jTuples/stargazers","contributors_url":"https://api.github.com/repos/git-afsantos/jTuples/contributors","subscribers_url":"https://api.github.com/repos/git-afsantos/jTuples/subscribers","subscription_url":"https://api.github.com/repos/git-afsantos/jTuples/subscription","commits_url":"https://api.github.com/repos/git-afsantos/jTuples/commits{/sha}","git_commits_url":"https://api.github.com/repos/git-afsantos/jTuples/git/commits{/sha}","comments_url":"https://api.github.com/repos/git-afsantos/jTuples/comments{/number}","issue_comment_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/comments{/number}","contents_url":"https://api.github.com/repos/git-afsantos/jTuples/contents/{+path}","compare_url":"https://api.github.com/repos/git-afsantos/jTuples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/git-afsantos/jTuples/merges","archive_url":"https://api.github.com/repos/git-afsantos/jTuples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/git-afsantos/jTuples/downloads","issues_url":"https://api.github.com/repos/git-afsantos/jTuples/issues{/number}","pulls_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls{/number}","milestones_url":"https://api.github.com/repos/git-afsantos/jTuples/milestones{/number}","notifications_url":"https://api.github.com/repos/git-afsantos/jTuples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/git-afsantos/jTuples/labels{/name}","releases_url":"https://api.github.com/repos/git-afsantos/jTuples/releases{/id}","created_at":"2015-05-06T19:34:17Z","updated_at":"2015-05-08T09:23:09Z","pushed_at":"2015-07-09T14:48:31Z","git_url":"git://github.com/git-afsantos/jTuples.git","ssh_url":"git@github.com:git-afsantos/jTuples.git","clone_url":"https://github.com/git-afsantos/jTuples.git","svn_url":"https://github.com/git-afsantos/jTuples","homepage":"","size":504,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"git-afsantos:master","ref":"master","sha":"2662eb6a286b96c302017ea75959b5991ae5b18c","user":{"login":"git-afsantos","id":5166824,"avatar_url":"https://avatars.githubusercontent.com/u/5166824?v=3","gravatar_id":"","url":"https://api.github.com/users/git-afsantos","html_url":"https://github.com/git-afsantos","followers_url":"https://api.github.com/users/git-afsantos/followers","following_url":"https://api.github.com/users/git-afsantos/following{/other_user}","gists_url":"https://api.github.com/users/git-afsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/git-afsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-afsantos/subscriptions","organizations_url":"https://api.github.com/users/git-afsantos/orgs","repos_url":"https://api.github.com/users/git-afsantos/repos","events_url":"https://api.github.com/users/git-afsantos/events{/privacy}","received_events_url":"https://api.github.com/users/git-afsantos/received_events","type":"User","site_admin":false},"repo":{"id":35178869,"name":"jTuples","full_name":"git-afsantos/jTuples","owner":{"login":"git-afsantos","id":5166824,"avatar_url":"https://avatars.githubusercontent.com/u/5166824?v=3","gravatar_id":"","url":"https://api.github.com/users/git-afsantos","html_url":"https://github.com/git-afsantos","followers_url":"https://api.github.com/users/git-afsantos/followers","following_url":"https://api.github.com/users/git-afsantos/following{/other_user}","gists_url":"https://api.github.com/users/git-afsantos/gists{/gist_id}","starred_url":"https://api.github.com/users/git-afsantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/git-afsantos/subscriptions","organizations_url":"https://api.github.com/users/git-afsantos/orgs","repos_url":"https://api.github.com/users/git-afsantos/repos","events_url":"https://api.github.com/users/git-afsantos/events{/privacy}","received_events_url":"https://api.github.com/users/git-afsantos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/git-afsantos/jTuples","description":"Java gets a Pair.","fork":false,"url":"https://api.github.com/repos/git-afsantos/jTuples","forks_url":"https://api.github.com/repos/git-afsantos/jTuples/forks","keys_url":"https://api.github.com/repos/git-afsantos/jTuples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/git-afsantos/jTuples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/git-afsantos/jTuples/teams","hooks_url":"https://api.github.com/repos/git-afsantos/jTuples/hooks","issue_events_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/events{/number}","events_url":"https://api.github.com/repos/git-afsantos/jTuples/events","assignees_url":"https://api.github.com/repos/git-afsantos/jTuples/assignees{/user}","branches_url":"https://api.github.com/repos/git-afsantos/jTuples/branches{/branch}","tags_url":"https://api.github.com/repos/git-afsantos/jTuples/tags","blobs_url":"https://api.github.com/repos/git-afsantos/jTuples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/git-afsantos/jTuples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/git-afsantos/jTuples/git/refs{/sha}","trees_url":"https://api.github.com/repos/git-afsantos/jTuples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/git-afsantos/jTuples/statuses/{sha}","languages_url":"https://api.github.com/repos/git-afsantos/jTuples/languages","stargazers_url":"https://api.github.com/repos/git-afsantos/jTuples/stargazers","contributors_url":"https://api.github.com/repos/git-afsantos/jTuples/contributors","subscribers_url":"https://api.github.com/repos/git-afsantos/jTuples/subscribers","subscription_url":"https://api.github.com/repos/git-afsantos/jTuples/subscription","commits_url":"https://api.github.com/repos/git-afsantos/jTuples/commits{/sha}","git_commits_url":"https://api.github.com/repos/git-afsantos/jTuples/git/commits{/sha}","comments_url":"https://api.github.com/repos/git-afsantos/jTuples/comments{/number}","issue_comment_url":"https://api.github.com/repos/git-afsantos/jTuples/issues/comments{/number}","contents_url":"https://api.github.com/repos/git-afsantos/jTuples/contents/{+path}","compare_url":"https://api.github.com/repos/git-afsantos/jTuples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/git-afsantos/jTuples/merges","archive_url":"https://api.github.com/repos/git-afsantos/jTuples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/git-afsantos/jTuples/downloads","issues_url":"https://api.github.com/repos/git-afsantos/jTuples/issues{/number}","pulls_url":"https://api.github.com/repos/git-afsantos/jTuples/pulls{/number}","milestones_url":"https://api.github.com/repos/git-afsantos/jTuples/milestones{/number}","notifications_url":"https://api.github.com/repos/git-afsantos/jTuples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/git-afsantos/jTuples/labels{/name}","releases_url":"https://api.github.com/repos/git-afsantos/jTuples/releases{/id}","created_at":"2015-05-06T19:34:17Z","updated_at":"2015-05-08T09:23:09Z","pushed_at":"2015-07-09T14:48:31Z","git_url":"git://github.com/git-afsantos/jTuples.git","ssh_url":"git@github.com:git-afsantos/jTuples.git","clone_url":"https://github.com/git-afsantos/jTuples.git","svn_url":"https://github.com/git-afsantos/jTuples","homepage":"","size":504,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/17"},"html":{"href":"https://github.com/git-afsantos/jTuples/pull/17"},"issue":{"href":"https://api.github.com/repos/git-afsantos/jTuples/issues/17"},"comments":{"href":"https://api.github.com/repos/git-afsantos/jTuples/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/git-afsantos/jTuples/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/git-afsantos/jTuples/statuses/a361164fa77085261e60748b8dba795b669f2684"}}}}