{"action":"created","comment":{"url":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/comments/22966465","id":22966465,"diff_hunk":"@@ -0,0 +1,557 @@\n+/**\n+ * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies\n+ *\n+ * Please see distribution for license.\n+ */\n+package com.opengamma.basics.currency;\n+\n+import static com.opengamma.collect.Guavate.entriesToImmutableMap;\n+\n+import java.util.Arrays;\n+import java.util.HashMap;\n+import java.util.LinkedHashMap;\n+import java.util.Map;\n+import java.util.Optional;\n+import java.util.function.BiConsumer;\n+import java.util.stream.Collector;\n+import java.util.stream.Collectors;\n+import java.util.stream.Stream;\n+\n+import com.google.common.collect.ImmutableMap;\n+import com.google.common.collect.ImmutableSet;\n+import com.opengamma.collect.ArgChecker;\n+import com.opengamma.collect.tuple.Pair;\n+\n+/**\n+ * Immutable class describing a set of currencies and all the cross rates between them.\n+ */\n+public class FxMatrix {\n+\n+  /**\n+   * An FX matrix containing neither currencies nor rates.\n+   */\n+  public static final FxMatrix EMPTY_FX_MATRIX = builder().build();\n+\n+  /**\n+   * The map between the currencies and their order. An ImmutableMap is","path":"modules/basics/src/main/java/com/opengamma/basics/currency/FxMatrix.java","position":36,"original_position":36,"commit_id":"3e1299e0f4896d07fce69a78c3986bdd1c8111fc","original_commit_id":"3e1299e0f4896d07fce69a78c3986bdd1c8111fc","user":{"login":"cjkent","id":98477,"avatar_url":"https://avatars.githubusercontent.com/u/98477?v=3","gravatar_id":"","url":"https://api.github.com/users/cjkent","html_url":"https://github.com/cjkent","followers_url":"https://api.github.com/users/cjkent/followers","following_url":"https://api.github.com/users/cjkent/following{/other_user}","gists_url":"https://api.github.com/users/cjkent/gists{/gist_id}","starred_url":"https://api.github.com/users/cjkent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjkent/subscriptions","organizations_url":"https://api.github.com/users/cjkent/orgs","repos_url":"https://api.github.com/users/cjkent/repos","events_url":"https://api.github.com/users/cjkent/events{/privacy}","received_events_url":"https://api.github.com/users/cjkent/received_events","type":"User","site_admin":false},"body":"Elaborate on what this is for. When I read it I thought \"what order?\". It was only when I read the Javadoc below that I realised it's the index of the currencies row in ``rates``.","created_at":"2015-01-14T20:16:14Z","updated_at":"2015-01-14T20:16:14Z","html_url":"https://github.com/OpenGamma/OG-Commons/pull/45#discussion_r22966465","pull_request_url":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/45","_links":{"self":{"href":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/comments/22966465"},"html":{"href":"https://github.com/OpenGamma/OG-Commons/pull/45#discussion_r22966465"},"pull_request":{"href":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/45","id":27370595,"html_url":"https://github.com/OpenGamma/OG-Commons/pull/45","diff_url":"https://github.com/OpenGamma/OG-Commons/pull/45.diff","patch_url":"https://github.com/OpenGamma/OG-Commons/pull/45.patch","issue_url":"https://api.github.com/repos/OpenGamma/OG-Commons/issues/45","number":45,"state":"open","locked":false,"title":"PLT-586 - Creation of an immutable FxMatrix class","user":{"login":"julianhowarth","id":3205453,"avatar_url":"https://avatars.githubusercontent.com/u/3205453?v=3","gravatar_id":"","url":"https://api.github.com/users/julianhowarth","html_url":"https://github.com/julianhowarth","followers_url":"https://api.github.com/users/julianhowarth/followers","following_url":"https://api.github.com/users/julianhowarth/following{/other_user}","gists_url":"https://api.github.com/users/julianhowarth/gists{/gist_id}","starred_url":"https://api.github.com/users/julianhowarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julianhowarth/subscriptions","organizations_url":"https://api.github.com/users/julianhowarth/orgs","repos_url":"https://api.github.com/users/julianhowarth/repos","events_url":"https://api.github.com/users/julianhowarth/events{/privacy}","received_events_url":"https://api.github.com/users/julianhowarth/received_events","type":"User","site_admin":false},"body":"This PR contains a new immutable FX Matrix for\r\ncurrency conversions. Whilst the data structure\r\nis more or less the same as the original FxMatrix\r\nin v2, there is no mutability. Instead a mutable\r\nbuilder is provided.\r\n\r\nThe other main differences to the original class\r\nare:\r\n - the ability to add a rate with no currencies in\r\n   common with the matrix with the expectation that\r\n   other additions will allow it to be added\r\n - the ability to handle a collection of rates\r\n - the ability to collect a stream of rates directly\r\n   into a new FxMatrix\r\n\r\nThe builder has been implemented such that its\r\nunderlying matrix is not resized for every currency\r\naddition, but only periodically (it doubles in size\r\nwhen needed). This hopefully balances between too much\r\nresizing and too much memory but interested in other\r\nviews.\r\n\r\nTest coverage is at 100%.","created_at":"2015-01-14T18:14:50Z","updated_at":"2015-01-14T20:16:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cc208a02feb2e749a26c7911fb22a60efc0613c8","assignee":{"login":"jodastephen","id":213212,"avatar_url":"https://avatars.githubusercontent.com/u/213212?v=3","gravatar_id":"","url":"https://api.github.com/users/jodastephen","html_url":"https://github.com/jodastephen","followers_url":"https://api.github.com/users/jodastephen/followers","following_url":"https://api.github.com/users/jodastephen/following{/other_user}","gists_url":"https://api.github.com/users/jodastephen/gists{/gist_id}","starred_url":"https://api.github.com/users/jodastephen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jodastephen/subscriptions","organizations_url":"https://api.github.com/users/jodastephen/orgs","repos_url":"https://api.github.com/users/jodastephen/repos","events_url":"https://api.github.com/users/jodastephen/events{/privacy}","received_events_url":"https://api.github.com/users/jodastephen/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/45/commits","review_comments_url":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/45/comments","review_comment_url":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/comments/{number}","comments_url":"https://api.github.com/repos/OpenGamma/OG-Commons/issues/45/comments","statuses_url":"https://api.github.com/repos/OpenGamma/OG-Commons/statuses/3e1299e0f4896d07fce69a78c3986bdd1c8111fc","head":{"label":"OpenGamma:topic/PLT-586","ref":"topic/PLT-586","sha":"3e1299e0f4896d07fce69a78c3986bdd1c8111fc","user":{"login":"OpenGamma","id":120064,"avatar_url":"https://avatars.githubusercontent.com/u/120064?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenGamma","html_url":"https://github.com/OpenGamma","followers_url":"https://api.github.com/users/OpenGamma/followers","following_url":"https://api.github.com/users/OpenGamma/following{/other_user}","gists_url":"https://api.github.com/users/OpenGamma/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenGamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenGamma/subscriptions","organizations_url":"https://api.github.com/users/OpenGamma/orgs","repos_url":"https://api.github.com/users/OpenGamma/repos","events_url":"https://api.github.com/users/OpenGamma/events{/privacy}","received_events_url":"https://api.github.com/users/OpenGamma/received_events","type":"Organization","site_admin":false},"repo":{"id":20916831,"name":"OG-Commons","full_name":"OpenGamma/OG-Commons","owner":{"login":"OpenGamma","id":120064,"avatar_url":"https://avatars.githubusercontent.com/u/120064?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenGamma","html_url":"https://github.com/OpenGamma","followers_url":"https://api.github.com/users/OpenGamma/followers","following_url":"https://api.github.com/users/OpenGamma/following{/other_user}","gists_url":"https://api.github.com/users/OpenGamma/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenGamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenGamma/subscriptions","organizations_url":"https://api.github.com/users/OpenGamma/orgs","repos_url":"https://api.github.com/users/OpenGamma/repos","events_url":"https://api.github.com/users/OpenGamma/events{/privacy}","received_events_url":"https://api.github.com/users/OpenGamma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenGamma/OG-Commons","description":"Libraries of common code supporting OpenGamma","fork":false,"url":"https://api.github.com/repos/OpenGamma/OG-Commons","forks_url":"https://api.github.com/repos/OpenGamma/OG-Commons/forks","keys_url":"https://api.github.com/repos/OpenGamma/OG-Commons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenGamma/OG-Commons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenGamma/OG-Commons/teams","hooks_url":"https://api.github.com/repos/OpenGamma/OG-Commons/hooks","issue_events_url":"https://api.github.com/repos/OpenGamma/OG-Commons/issues/events{/number}","events_url":"https://api.github.com/repos/OpenGamma/OG-Commons/events","assignees_url":"https://api.github.com/repos/OpenGamma/OG-Commons/assignees{/user}","branches_url":"https://api.github.com/repos/OpenGamma/OG-Commons/branches{/branch}","tags_url":"https://api.github.com/repos/OpenGamma/OG-Commons/tags","blobs_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenGamma/OG-Commons/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenGamma/OG-Commons/languages","stargazers_url":"https://api.github.com/repos/OpenGamma/OG-Commons/stargazers","contributors_url":"https://api.github.com/repos/OpenGamma/OG-Commons/contributors","subscribers_url":"https://api.github.com/repos/OpenGamma/OG-Commons/subscribers","subscription_url":"https://api.github.com/repos/OpenGamma/OG-Commons/subscription","commits_url":"https://api.github.com/repos/OpenGamma/OG-Commons/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenGamma/OG-Commons/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenGamma/OG-Commons/issues/comments/{number}","contents_url":"https://api.github.com/repos/OpenGamma/OG-Commons/contents/{+path}","compare_url":"https://api.github.com/repos/OpenGamma/OG-Commons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenGamma/OG-Commons/merges","archive_url":"https://api.github.com/repos/OpenGamma/OG-Commons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenGamma/OG-Commons/downloads","issues_url":"https://api.github.com/repos/OpenGamma/OG-Commons/issues{/number}","pulls_url":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenGamma/OG-Commons/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenGamma/OG-Commons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenGamma/OG-Commons/labels{/name}","releases_url":"https://api.github.com/repos/OpenGamma/OG-Commons/releases{/id}","created_at":"2014-06-17T08:59:44Z","updated_at":"2015-01-14T11:00:39Z","pushed_at":"2015-01-14T18:11:55Z","git_url":"git://github.com/OpenGamma/OG-Commons.git","ssh_url":"git@github.com:OpenGamma/OG-Commons.git","clone_url":"https://github.com/OpenGamma/OG-Commons.git","svn_url":"https://github.com/OpenGamma/OG-Commons","homepage":"","size":2370,"stargazers_count":11,"watchers_count":11,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":11,"default_branch":"master"}},"base":{"label":"OpenGamma:master","ref":"master","sha":"570e0d194f0964231aadff01ebe8c2bb3b0c9aad","user":{"login":"OpenGamma","id":120064,"avatar_url":"https://avatars.githubusercontent.com/u/120064?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenGamma","html_url":"https://github.com/OpenGamma","followers_url":"https://api.github.com/users/OpenGamma/followers","following_url":"https://api.github.com/users/OpenGamma/following{/other_user}","gists_url":"https://api.github.com/users/OpenGamma/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenGamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenGamma/subscriptions","organizations_url":"https://api.github.com/users/OpenGamma/orgs","repos_url":"https://api.github.com/users/OpenGamma/repos","events_url":"https://api.github.com/users/OpenGamma/events{/privacy}","received_events_url":"https://api.github.com/users/OpenGamma/received_events","type":"Organization","site_admin":false},"repo":{"id":20916831,"name":"OG-Commons","full_name":"OpenGamma/OG-Commons","owner":{"login":"OpenGamma","id":120064,"avatar_url":"https://avatars.githubusercontent.com/u/120064?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenGamma","html_url":"https://github.com/OpenGamma","followers_url":"https://api.github.com/users/OpenGamma/followers","following_url":"https://api.github.com/users/OpenGamma/following{/other_user}","gists_url":"https://api.github.com/users/OpenGamma/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenGamma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenGamma/subscriptions","organizations_url":"https://api.github.com/users/OpenGamma/orgs","repos_url":"https://api.github.com/users/OpenGamma/repos","events_url":"https://api.github.com/users/OpenGamma/events{/privacy}","received_events_url":"https://api.github.com/users/OpenGamma/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenGamma/OG-Commons","description":"Libraries of common code supporting OpenGamma","fork":false,"url":"https://api.github.com/repos/OpenGamma/OG-Commons","forks_url":"https://api.github.com/repos/OpenGamma/OG-Commons/forks","keys_url":"https://api.github.com/repos/OpenGamma/OG-Commons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenGamma/OG-Commons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenGamma/OG-Commons/teams","hooks_url":"https://api.github.com/repos/OpenGamma/OG-Commons/hooks","issue_events_url":"https://api.github.com/repos/OpenGamma/OG-Commons/issues/events{/number}","events_url":"https://api.github.com/repos/OpenGamma/OG-Commons/events","assignees_url":"https://api.github.com/repos/OpenGamma/OG-Commons/assignees{/user}","branches_url":"https://api.github.com/repos/OpenGamma/OG-Commons/branches{/branch}","tags_url":"https://api.github.com/repos/OpenGamma/OG-Commons/tags","blobs_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenGamma/OG-Commons/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenGamma/OG-Commons/languages","stargazers_url":"https://api.github.com/repos/OpenGamma/OG-Commons/stargazers","contributors_url":"https://api.github.com/repos/OpenGamma/OG-Commons/contributors","subscribers_url":"https://api.github.com/repos/OpenGamma/OG-Commons/subscribers","subscription_url":"https://api.github.com/repos/OpenGamma/OG-Commons/subscription","commits_url":"https://api.github.com/repos/OpenGamma/OG-Commons/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenGamma/OG-Commons/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenGamma/OG-Commons/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenGamma/OG-Commons/issues/comments/{number}","contents_url":"https://api.github.com/repos/OpenGamma/OG-Commons/contents/{+path}","compare_url":"https://api.github.com/repos/OpenGamma/OG-Commons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenGamma/OG-Commons/merges","archive_url":"https://api.github.com/repos/OpenGamma/OG-Commons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenGamma/OG-Commons/downloads","issues_url":"https://api.github.com/repos/OpenGamma/OG-Commons/issues{/number}","pulls_url":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenGamma/OG-Commons/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenGamma/OG-Commons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenGamma/OG-Commons/labels{/name}","releases_url":"https://api.github.com/repos/OpenGamma/OG-Commons/releases{/id}","created_at":"2014-06-17T08:59:44Z","updated_at":"2015-01-14T11:00:39Z","pushed_at":"2015-01-14T18:11:55Z","git_url":"git://github.com/OpenGamma/OG-Commons.git","ssh_url":"git@github.com:OpenGamma/OG-Commons.git","clone_url":"https://github.com/OpenGamma/OG-Commons.git","svn_url":"https://github.com/OpenGamma/OG-Commons","homepage":"","size":2370,"stargazers_count":11,"watchers_count":11,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/45"},"html":{"href":"https://github.com/OpenGamma/OG-Commons/pull/45"},"issue":{"href":"https://api.github.com/repos/OpenGamma/OG-Commons/issues/45"},"comments":{"href":"https://api.github.com/repos/OpenGamma/OG-Commons/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/OpenGamma/OG-Commons/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/OpenGamma/OG-Commons/statuses/3e1299e0f4896d07fce69a78c3986bdd1c8111fc"}}}}