{"action":"created","comment":{"url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments/85895372","pull_request_review_id":6578733,"id":85895372,"diff_hunk":"@@ -0,0 +1,173 @@\n+package ru.mipt.java2016.homework.g596.pockonechny.task2;\n+\n+import ru.mipt.java2016.homework.base.task2.KeyValueStorage;\n+\n+import java.io.File;\n+import java.io.IOException;\n+import java.io.DataOutputStream;\n+import java.io.DataInputStream;\n+import java.io.FileOutputStream;\n+import java.io.FileInputStream;\n+\n+import java.nio.file.Files;\n+import java.util.HashMap;\n+import java.util.Iterator;\n+import java.util.Map;\n+\n+/**\n+ * Created by celidos on 30.10.16.\n+ */\n+\n+public class AdvancedKeyValueStorage<K, V> implements KeyValueStorage<K, V> {\n+\n+    private static final String DEFAULT_FILENAME = \"storage.txt\";\n+\n+    private enum ContentType { STRING_TO_STRING, INT_TO_DOUBLE, STUDENTKEY_TO_STUDENT }\n+\n+    // ---------------------------------\n+\n+    private String filename;\n+    private ContentType contentType;\n+    private HashMap<K, V> hashmap;\n+    private boolean isStreamingNow;\n+    private SerializationStrategy<K> keySerializator;\n+    private SerializationStrategy<V> valueSerializator;\n+\n+    // ---------------------------------\n+\n+    private void checkPathExistance(String path) throws IllegalStateException {\n+        File pathref = new File(path);\n+        if (!pathref.exists() || !pathref.isDirectory() || pathref.exists() == Files.notExists(pathref.toPath())) {\n+            throw new IllegalStateException(\"Error: path is not available / Undefined path state\");\n+        }\n+    }\n+\n+    private File checkFileIsOk(String fileName) throws IllegalStateException {\n+\n+        File file = new File(fileName);\n+\n+        if (!file.exists()) {\n+            try {\n+                file.createNewFile();\n+            } catch (IOException e) {\n+                throw new IllegalStateException(\"Error: cannot create file\");\n+            }\n+\n+            try (DataOutputStream writerDevice = new DataOutputStream(new FileOutputStream(fileName))) {\n+                writerDevice.writeUTF(contentType.toString());\n+                writerDevice.writeInt(0);\n+            } catch (IOException e) {\n+                throw new IllegalStateException(\"Error: no acсess to the file\");\n+            }\n+        }\n+        return file;\n+    }\n+\n+    private void checkStorageAviability() {\n+        if (!isStreamingNow) {\n+            throw new IllegalStateException(\"Error: operation refer to closed storage\");\n+        }\n+    }\n+\n+    private void readDataFromDevice(DataInputStream readingDevice) throws IOException {\n+        try {\n+            int number = readingDevice.readInt();\n+            for (int i = 0; i < number; ++i) {\n+                K key = keySerializator.read(readingDevice);\n+                V val = valueSerializator.read(readingDevice);\n+                hashmap.put(key, val);\n+            }\n+        } catch (IOException e) {\n+            throw new IllegalStateException(\"Error: invalid data format inside file\");\n+        }\n+    }\n+\n+    private void writeDataToDevice(DataOutputStream writingDevice) throws IOException {\n+        writingDevice.writeUTF(contentType.toString());\n+        writingDevice.writeInt(hashmap.size());\n+\n+        for (Map.Entry<K, V> entry: hashmap.entrySet()) {\n+            keySerializator.write(writingDevice, entry.getKey());\n+            valueSerializator.write(writingDevice, entry.getValue());\n+        }\n+    }\n+\n+    public AdvancedKeyValueStorage(String path, SerializationStrategy serialKey,\n+                                   SerializationStrategy serialValue, String content) {\n+\n+        // -------------------------\n+\n+        filename = path + \"/\" + DEFAULT_FILENAME;","path":"homework-g596-pockonechny/src/main/java/ru/mipt/java2016/homework/g596/pockonechny/task2/AdvancedKeyValueStorage.java","position":100,"original_position":100,"commit_id":"686393176683d4557f445287fee6b4d609a75a9f","original_commit_id":"686393176683d4557f445287fee6b4d609a75a9f","user":{"login":"DanAnastasyev","id":5503582,"avatar_url":"https://avatars.githubusercontent.com/u/5503582?v=3","gravatar_id":"","url":"https://api.github.com/users/DanAnastasyev","html_url":"https://github.com/DanAnastasyev","followers_url":"https://api.github.com/users/DanAnastasyev/followers","following_url":"https://api.github.com/users/DanAnastasyev/following{/other_user}","gists_url":"https://api.github.com/users/DanAnastasyev/gists{/gist_id}","starred_url":"https://api.github.com/users/DanAnastasyev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanAnastasyev/subscriptions","organizations_url":"https://api.github.com/users/DanAnastasyev/orgs","repos_url":"https://api.github.com/users/DanAnastasyev/repos","events_url":"https://api.github.com/users/DanAnastasyev/events{/privacy}","received_events_url":"https://api.github.com/users/DanAnastasyev/received_events","type":"User","site_admin":false},"body":"Используй `File.separator` вместо `\"/\"`","created_at":"2016-11-01T09:17:22Z","updated_at":"2016-11-01T09:25:21Z","html_url":"https://github.com/fediq/mipt-java-2016/pull/63#discussion_r85895372","pull_request_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments/85895372"},"html":{"href":"https://github.com/fediq/mipt-java-2016/pull/63#discussion_r85895372"},"pull_request":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/63","id":89160868,"html_url":"https://github.com/fediq/mipt-java-2016/pull/63","diff_url":"https://github.com/fediq/mipt-java-2016/pull/63.diff","patch_url":"https://github.com/fediq/mipt-java-2016/pull/63.patch","issue_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/63","number":63,"state":"open","locked":false,"title":"g596.pockonechny.task2","user":{"login":"epockonechny","id":22798039,"avatar_url":"https://avatars.githubusercontent.com/u/22798039?v=3","gravatar_id":"","url":"https://api.github.com/users/epockonechny","html_url":"https://github.com/epockonechny","followers_url":"https://api.github.com/users/epockonechny/followers","following_url":"https://api.github.com/users/epockonechny/following{/other_user}","gists_url":"https://api.github.com/users/epockonechny/gists{/gist_id}","starred_url":"https://api.github.com/users/epockonechny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epockonechny/subscriptions","organizations_url":"https://api.github.com/users/epockonechny/orgs","repos_url":"https://api.github.com/users/epockonechny/repos","events_url":"https://api.github.com/users/epockonechny/events{/privacy}","received_events_url":"https://api.github.com/users/epockonechny/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-13T08:57:49Z","updated_at":"2016-11-01T09:25:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5eb591c18d1aeb8e7a723d3acc0d9a016eb87a51","assignee":{"login":"DanAnastasyev","id":5503582,"avatar_url":"https://avatars.githubusercontent.com/u/5503582?v=3","gravatar_id":"","url":"https://api.github.com/users/DanAnastasyev","html_url":"https://github.com/DanAnastasyev","followers_url":"https://api.github.com/users/DanAnastasyev/followers","following_url":"https://api.github.com/users/DanAnastasyev/following{/other_user}","gists_url":"https://api.github.com/users/DanAnastasyev/gists{/gist_id}","starred_url":"https://api.github.com/users/DanAnastasyev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanAnastasyev/subscriptions","organizations_url":"https://api.github.com/users/DanAnastasyev/orgs","repos_url":"https://api.github.com/users/DanAnastasyev/repos","events_url":"https://api.github.com/users/DanAnastasyev/events{/privacy}","received_events_url":"https://api.github.com/users/DanAnastasyev/received_events","type":"User","site_admin":false},"assignees":[{"login":"DanAnastasyev","id":5503582,"avatar_url":"https://avatars.githubusercontent.com/u/5503582?v=3","gravatar_id":"","url":"https://api.github.com/users/DanAnastasyev","html_url":"https://github.com/DanAnastasyev","followers_url":"https://api.github.com/users/DanAnastasyev/followers","following_url":"https://api.github.com/users/DanAnastasyev/following{/other_user}","gists_url":"https://api.github.com/users/DanAnastasyev/gists{/gist_id}","starred_url":"https://api.github.com/users/DanAnastasyev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanAnastasyev/subscriptions","organizations_url":"https://api.github.com/users/DanAnastasyev/orgs","repos_url":"https://api.github.com/users/DanAnastasyev/repos","events_url":"https://api.github.com/users/DanAnastasyev/events{/privacy}","received_events_url":"https://api.github.com/users/DanAnastasyev/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/63/commits","review_comments_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/63/comments","review_comment_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/63/comments","statuses_url":"https://api.github.com/repos/fediq/mipt-java-2016/statuses/686393176683d4557f445287fee6b4d609a75a9f","head":{"label":"epockonechny:master","ref":"master","sha":"686393176683d4557f445287fee6b4d609a75a9f","user":{"login":"epockonechny","id":22798039,"avatar_url":"https://avatars.githubusercontent.com/u/22798039?v=3","gravatar_id":"","url":"https://api.github.com/users/epockonechny","html_url":"https://github.com/epockonechny","followers_url":"https://api.github.com/users/epockonechny/followers","following_url":"https://api.github.com/users/epockonechny/following{/other_user}","gists_url":"https://api.github.com/users/epockonechny/gists{/gist_id}","starred_url":"https://api.github.com/users/epockonechny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epockonechny/subscriptions","organizations_url":"https://api.github.com/users/epockonechny/orgs","repos_url":"https://api.github.com/users/epockonechny/repos","events_url":"https://api.github.com/users/epockonechny/events{/privacy}","received_events_url":"https://api.github.com/users/epockonechny/received_events","type":"User","site_admin":false},"repo":{"id":70721528,"name":"mipt-java-2016","full_name":"epockonechny/mipt-java-2016","owner":{"login":"epockonechny","id":22798039,"avatar_url":"https://avatars.githubusercontent.com/u/22798039?v=3","gravatar_id":"","url":"https://api.github.com/users/epockonechny","html_url":"https://github.com/epockonechny","followers_url":"https://api.github.com/users/epockonechny/followers","following_url":"https://api.github.com/users/epockonechny/following{/other_user}","gists_url":"https://api.github.com/users/epockonechny/gists{/gist_id}","starred_url":"https://api.github.com/users/epockonechny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epockonechny/subscriptions","organizations_url":"https://api.github.com/users/epockonechny/orgs","repos_url":"https://api.github.com/users/epockonechny/repos","events_url":"https://api.github.com/users/epockonechny/events{/privacy}","received_events_url":"https://api.github.com/users/epockonechny/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/epockonechny/mipt-java-2016","description":"Практическая часть курса \"Программирование на Java\", 2016 год","fork":true,"url":"https://api.github.com/repos/epockonechny/mipt-java-2016","forks_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/forks","keys_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/keys{/key_id}","collaborators_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/teams","hooks_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/hooks","issue_events_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/issues/events{/number}","events_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/events","assignees_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/assignees{/user}","branches_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/branches{/branch}","tags_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/tags","blobs_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/git/refs{/sha}","trees_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/git/trees{/sha}","statuses_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/statuses/{sha}","languages_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/languages","stargazers_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/stargazers","contributors_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/contributors","subscribers_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/subscribers","subscription_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/subscription","commits_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/commits{/sha}","git_commits_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/git/commits{/sha}","comments_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/comments{/number}","issue_comment_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/issues/comments{/number}","contents_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/contents/{+path}","compare_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/compare/{base}...{head}","merges_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/merges","archive_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/downloads","issues_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/issues{/number}","pulls_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/pulls{/number}","milestones_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/milestones{/number}","notifications_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/labels{/name}","releases_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/releases{/id}","deployments_url":"https://api.github.com/repos/epockonechny/mipt-java-2016/deployments","created_at":"2016-10-12T16:57:40Z","updated_at":"2016-10-12T16:57:41Z","pushed_at":"2016-10-31T20:34:07Z","git_url":"git://github.com/epockonechny/mipt-java-2016.git","ssh_url":"git@github.com:epockonechny/mipt-java-2016.git","clone_url":"https://github.com/epockonechny/mipt-java-2016.git","svn_url":"https://github.com/epockonechny/mipt-java-2016","homepage":null,"size":1003,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"fediq:master","ref":"master","sha":"ffdcbce8e91f1b7dc1ffe4ad9c2a911f1609341d","user":{"login":"fediq","id":1057798,"avatar_url":"https://avatars.githubusercontent.com/u/1057798?v=3","gravatar_id":"","url":"https://api.github.com/users/fediq","html_url":"https://github.com/fediq","followers_url":"https://api.github.com/users/fediq/followers","following_url":"https://api.github.com/users/fediq/following{/other_user}","gists_url":"https://api.github.com/users/fediq/gists{/gist_id}","starred_url":"https://api.github.com/users/fediq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fediq/subscriptions","organizations_url":"https://api.github.com/users/fediq/orgs","repos_url":"https://api.github.com/users/fediq/repos","events_url":"https://api.github.com/users/fediq/events{/privacy}","received_events_url":"https://api.github.com/users/fediq/received_events","type":"User","site_admin":false},"repo":{"id":69496783,"name":"mipt-java-2016","full_name":"fediq/mipt-java-2016","owner":{"login":"fediq","id":1057798,"avatar_url":"https://avatars.githubusercontent.com/u/1057798?v=3","gravatar_id":"","url":"https://api.github.com/users/fediq","html_url":"https://github.com/fediq","followers_url":"https://api.github.com/users/fediq/followers","following_url":"https://api.github.com/users/fediq/following{/other_user}","gists_url":"https://api.github.com/users/fediq/gists{/gist_id}","starred_url":"https://api.github.com/users/fediq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fediq/subscriptions","organizations_url":"https://api.github.com/users/fediq/orgs","repos_url":"https://api.github.com/users/fediq/repos","events_url":"https://api.github.com/users/fediq/events{/privacy}","received_events_url":"https://api.github.com/users/fediq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fediq/mipt-java-2016","description":"Практическая часть курса \"Программирование на Java\", 2016 год","fork":false,"url":"https://api.github.com/repos/fediq/mipt-java-2016","forks_url":"https://api.github.com/repos/fediq/mipt-java-2016/forks","keys_url":"https://api.github.com/repos/fediq/mipt-java-2016/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fediq/mipt-java-2016/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fediq/mipt-java-2016/teams","hooks_url":"https://api.github.com/repos/fediq/mipt-java-2016/hooks","issue_events_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/events{/number}","events_url":"https://api.github.com/repos/fediq/mipt-java-2016/events","assignees_url":"https://api.github.com/repos/fediq/mipt-java-2016/assignees{/user}","branches_url":"https://api.github.com/repos/fediq/mipt-java-2016/branches{/branch}","tags_url":"https://api.github.com/repos/fediq/mipt-java-2016/tags","blobs_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/refs{/sha}","trees_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fediq/mipt-java-2016/statuses/{sha}","languages_url":"https://api.github.com/repos/fediq/mipt-java-2016/languages","stargazers_url":"https://api.github.com/repos/fediq/mipt-java-2016/stargazers","contributors_url":"https://api.github.com/repos/fediq/mipt-java-2016/contributors","subscribers_url":"https://api.github.com/repos/fediq/mipt-java-2016/subscribers","subscription_url":"https://api.github.com/repos/fediq/mipt-java-2016/subscription","commits_url":"https://api.github.com/repos/fediq/mipt-java-2016/commits{/sha}","git_commits_url":"https://api.github.com/repos/fediq/mipt-java-2016/git/commits{/sha}","comments_url":"https://api.github.com/repos/fediq/mipt-java-2016/comments{/number}","issue_comment_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues/comments{/number}","contents_url":"https://api.github.com/repos/fediq/mipt-java-2016/contents/{+path}","compare_url":"https://api.github.com/repos/fediq/mipt-java-2016/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fediq/mipt-java-2016/merges","archive_url":"https://api.github.com/repos/fediq/mipt-java-2016/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fediq/mipt-java-2016/downloads","issues_url":"https://api.github.com/repos/fediq/mipt-java-2016/issues{/number}","pulls_url":"https://api.github.com/repos/fediq/mipt-java-2016/pulls{/number}","milestones_url":"https://api.github.com/repos/fediq/mipt-java-2016/milestones{/number}","notifications_url":"https://api.github.com/repos/fediq/mipt-java-2016/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fediq/mipt-java-2016/labels{/name}","releases_url":"https://api.github.com/repos/fediq/mipt-java-2016/releases{/id}","deployments_url":"https://api.github.com/repos/fediq/mipt-java-2016/deployments","created_at":"2016-09-28T19:29:28Z","updated_at":"2016-10-22T20:34:58Z","pushed_at":"2016-11-01T07:46:46Z","git_url":"git://github.com/fediq/mipt-java-2016.git","ssh_url":"git@github.com:fediq/mipt-java-2016.git","clone_url":"https://github.com/fediq/mipt-java-2016.git","svn_url":"https://github.com/fediq/mipt-java-2016","homepage":null,"size":2213,"stargazers_count":13,"watchers_count":13,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":87,"mirror_url":null,"open_issues_count":54,"forks":87,"open_issues":54,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/63"},"html":{"href":"https://github.com/fediq/mipt-java-2016/pull/63"},"issue":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/issues/63"},"comments":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/fediq/mipt-java-2016/statuses/686393176683d4557f445287fee6b4d609a75a9f"}}}}
{"actor":{"display_login":"DanAnastasyev"}}