{"action":"created","comment":{"url":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/comments/171528862","pull_request_review_id":100394716,"id":171528862,"diff_hunk":"@@ -0,0 +1,190 @@\n+package ru.sberbank.homework.drozdov;\n+\n+import java.math.BigDecimal;\n+import java.math.BigInteger;\n+import java.util.HashMap;\n+\n+public class ExpressionChecker {\n+    private String expression;\n+    private StringBuilder refactorString;\n+    private HashMap<Integer, Character> validLiterals = new HashMap<>();\n+    private HashMap<Integer, Character> operations = new HashMap<>();\n+\n+    ExpressionChecker(String expression) {\n+        this.expression = expression;\n+        fillValidLiterals();\n+    }\n+\n+    /**\n+     * проверяем все ли числа в нашем выражении либо литерал целочисленного типа, либо вещественное число\n+     */\n+    public boolean isValid() {\n+        if (!checkWhitespacesAndBrackets()) {\n+            return false;\n+        }\n+        expression = expression.replaceAll(\"\\\\(\", \" ( \").replaceAll(\"\\\\)\", \" ) \");\n+        String[] arrayOfLiterals = expression.split(\"\\\\s+\");\n+        if (arrayOfLiterals.length == 2) {\n+            refactorString = new StringBuilder(\"error > wrong expression\");\n+            return false;\n+        }\n+        if (!checkSequenceOfOperations(arrayOfLiterals)) {\n+            refactorString = new StringBuilder(\"error > wrong expression\");\n+            return false;\n+        }\n+        refactorString = new StringBuilder();\n+        BigDecimal num;\n+        for (String arrayOfLiteral : arrayOfLiterals) {\n+            String currentString = arrayOfLiteral.toLowerCase();\n+            if (currentString.equals(\"\")) {\n+                continue;\n+            }\n+            if (!checkUnderscoresAndValidLiterals(currentString)) {\n+                return false;\n+            }\n+            if ((currentString.length() == 1) && ((operations.containsValue(currentString.charAt(0))) || (currentString.charAt(0) == '(') || (currentString.charAt(0) == ')'))) {\n+                refactorString.append(currentString.charAt(0)).append(\" \");\n+                continue;\n+            }\n+            try {\n+                String refactoringCurrentString = currentString.replaceAll(\"_\", \"\").replaceAll(\"l\", \"\");\n+                BigDecimal signDecimal = new BigDecimal(\"1\");\n+                if (refactoringCurrentString.startsWith(\"+\")) {\n+                    refactoringCurrentString = refactoringCurrentString.substring(1);\n+                } else if (refactoringCurrentString.startsWith(\"-\")) {\n+                    signDecimal = new BigDecimal(\"-1\");\n+                    refactoringCurrentString = refactoringCurrentString.substring(1);\n+                }\n+                if (refactoringCurrentString.startsWith(\"0x\")) {\n+                    num = new BigDecimal(new BigInteger(refactoringCurrentString.substring(2), 16).longValue()).multiply(signDecimal);\n+                } else if (refactoringCurrentString.startsWith(\"0b\")) {\n+                    num = new BigDecimal(new BigInteger(refactoringCurrentString.substring(2), 2).longValue()).multiply(signDecimal);\n+                } else if ((refactoringCurrentString.startsWith(\"0\")) && (refactoringCurrentString.length() > 1) && (refactoringCurrentString.charAt(1) != '.')) {\n+                    num = new BigDecimal(new BigInteger(refactoringCurrentString.substring(1), 8).longValue()).multiply(signDecimal);\n+                } else if (refactoringCurrentString.contains(\".\")) {\n+                    num = new BigDecimal(Double.valueOf(refactoringCurrentString)).multiply(signDecimal);\n+                } else {\n+                    num = new BigDecimal(new BigInteger(refactoringCurrentString).longValue()).multiply(signDecimal);\n+                }\n+            } catch (RuntimeException e) {\n+                refactorString = new StringBuilder(\"error > \" + currentString);\n+                return false;\n+            }\n+            refactorString.append(String.valueOf(num)).append(\" \");\n+        }\n+        return true;\n+    }\n+\n+    private boolean checkUnderscoresAndValidLiterals(String currentString) {\n+        boolean checkUnderscoresAndValidLiterals = false;\n+        for (int i = 0; i < currentString.length(); i++) {\n+            char curChar = currentString.charAt(i);\n+            if (curChar == '_') {\n+                if ((i == 0) || (i == currentString.length() - 1)) {\n+                    checkUnderscoresAndValidLiterals = true;\n+                } else {\n+                    char prevChar = currentString.charAt(i - 1);\n+                    char nextChar = currentString.charAt(i + 1);\n+                    if (!(((Character.isDigit(prevChar)) || ((prevChar >= 'a') && (prevChar <= 'f')) || (prevChar == '_')) && ((Character.isDigit(nextChar)) || ((nextChar >= 'a') && (nextChar <= 'f')) || (nextChar == '_')))) {","path":"hw02/src/main/java/ru/sberbank/homework/drozdov/ExpressionChecker.java","position":88,"original_position":88,"commit_id":"14dcbd9ad1de9a155919ad0af91541d8c885105a","original_commit_id":"14dcbd9ad1de9a155919ad0af91541d8c885105a","user":{"login":"bormoshka","id":1025327,"avatar_url":"https://avatars3.githubusercontent.com/u/1025327?v=4","gravatar_id":"","url":"https://api.github.com/users/bormoshka","html_url":"https://github.com/bormoshka","followers_url":"https://api.github.com/users/bormoshka/followers","following_url":"https://api.github.com/users/bormoshka/following{/other_user}","gists_url":"https://api.github.com/users/bormoshka/gists{/gist_id}","starred_url":"https://api.github.com/users/bormoshka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bormoshka/subscriptions","organizations_url":"https://api.github.com/users/bormoshka/orgs","repos_url":"https://api.github.com/users/bormoshka/repos","events_url":"https://api.github.com/users/bormoshka/events{/privacy}","received_events_url":"https://api.github.com/users/bormoshka/received_events","type":"User","site_admin":false},"body":"Сложновато","created_at":"2018-03-01T11:19:43Z","updated_at":"2018-03-01T11:22:38Z","html_url":"https://github.com/SberTechJavaSchool/Homework/pull/59#discussion_r171528862","pull_request_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/59","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/comments/171528862"},"html":{"href":"https://github.com/SberTechJavaSchool/Homework/pull/59#discussion_r171528862"},"pull_request":{"href":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/59"}}},"pull_request":{"url":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/59","id":169851013,"html_url":"https://github.com/SberTechJavaSchool/Homework/pull/59","diff_url":"https://github.com/SberTechJavaSchool/Homework/pull/59.diff","patch_url":"https://github.com/SberTechJavaSchool/Homework/pull/59.patch","issue_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/issues/59","number":59,"state":"open","locked":false,"title":"02. Дроздов Г","user":{"login":"DrozdikGleb","id":22279601,"avatar_url":"https://avatars3.githubusercontent.com/u/22279601?v=4","gravatar_id":"","url":"https://api.github.com/users/DrozdikGleb","html_url":"https://github.com/DrozdikGleb","followers_url":"https://api.github.com/users/DrozdikGleb/followers","following_url":"https://api.github.com/users/DrozdikGleb/following{/other_user}","gists_url":"https://api.github.com/users/DrozdikGleb/gists{/gist_id}","starred_url":"https://api.github.com/users/DrozdikGleb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrozdikGleb/subscriptions","organizations_url":"https://api.github.com/users/DrozdikGleb/orgs","repos_url":"https://api.github.com/users/DrozdikGleb/repos","events_url":"https://api.github.com/users/DrozdikGleb/events{/privacy}","received_events_url":"https://api.github.com/users/DrozdikGleb/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-18T21:31:12Z","updated_at":"2018-03-01T11:22:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f9eb5920ea360c00b8f8553b74efc71c66805dea","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/59/commits","review_comments_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/59/comments","review_comment_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/issues/59/comments","statuses_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/statuses/14dcbd9ad1de9a155919ad0af91541d8c885105a","head":{"label":"DrozdikGleb:hw2","ref":"hw2","sha":"14dcbd9ad1de9a155919ad0af91541d8c885105a","user":{"login":"DrozdikGleb","id":22279601,"avatar_url":"https://avatars3.githubusercontent.com/u/22279601?v=4","gravatar_id":"","url":"https://api.github.com/users/DrozdikGleb","html_url":"https://github.com/DrozdikGleb","followers_url":"https://api.github.com/users/DrozdikGleb/followers","following_url":"https://api.github.com/users/DrozdikGleb/following{/other_user}","gists_url":"https://api.github.com/users/DrozdikGleb/gists{/gist_id}","starred_url":"https://api.github.com/users/DrozdikGleb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrozdikGleb/subscriptions","organizations_url":"https://api.github.com/users/DrozdikGleb/orgs","repos_url":"https://api.github.com/users/DrozdikGleb/repos","events_url":"https://api.github.com/users/DrozdikGleb/events{/privacy}","received_events_url":"https://api.github.com/users/DrozdikGleb/received_events","type":"User","site_admin":false},"repo":{"id":120517010,"name":"Homework","full_name":"DrozdikGleb/Homework","owner":{"login":"DrozdikGleb","id":22279601,"avatar_url":"https://avatars3.githubusercontent.com/u/22279601?v=4","gravatar_id":"","url":"https://api.github.com/users/DrozdikGleb","html_url":"https://github.com/DrozdikGleb","followers_url":"https://api.github.com/users/DrozdikGleb/followers","following_url":"https://api.github.com/users/DrozdikGleb/following{/other_user}","gists_url":"https://api.github.com/users/DrozdikGleb/gists{/gist_id}","starred_url":"https://api.github.com/users/DrozdikGleb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrozdikGleb/subscriptions","organizations_url":"https://api.github.com/users/DrozdikGleb/orgs","repos_url":"https://api.github.com/users/DrozdikGleb/repos","events_url":"https://api.github.com/users/DrozdikGleb/events{/privacy}","received_events_url":"https://api.github.com/users/DrozdikGleb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DrozdikGleb/Homework","description":"Домашняя работа","fork":true,"url":"https://api.github.com/repos/DrozdikGleb/Homework","forks_url":"https://api.github.com/repos/DrozdikGleb/Homework/forks","keys_url":"https://api.github.com/repos/DrozdikGleb/Homework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DrozdikGleb/Homework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DrozdikGleb/Homework/teams","hooks_url":"https://api.github.com/repos/DrozdikGleb/Homework/hooks","issue_events_url":"https://api.github.com/repos/DrozdikGleb/Homework/issues/events{/number}","events_url":"https://api.github.com/repos/DrozdikGleb/Homework/events","assignees_url":"https://api.github.com/repos/DrozdikGleb/Homework/assignees{/user}","branches_url":"https://api.github.com/repos/DrozdikGleb/Homework/branches{/branch}","tags_url":"https://api.github.com/repos/DrozdikGleb/Homework/tags","blobs_url":"https://api.github.com/repos/DrozdikGleb/Homework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DrozdikGleb/Homework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DrozdikGleb/Homework/git/refs{/sha}","trees_url":"https://api.github.com/repos/DrozdikGleb/Homework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DrozdikGleb/Homework/statuses/{sha}","languages_url":"https://api.github.com/repos/DrozdikGleb/Homework/languages","stargazers_url":"https://api.github.com/repos/DrozdikGleb/Homework/stargazers","contributors_url":"https://api.github.com/repos/DrozdikGleb/Homework/contributors","subscribers_url":"https://api.github.com/repos/DrozdikGleb/Homework/subscribers","subscription_url":"https://api.github.com/repos/DrozdikGleb/Homework/subscription","commits_url":"https://api.github.com/repos/DrozdikGleb/Homework/commits{/sha}","git_commits_url":"https://api.github.com/repos/DrozdikGleb/Homework/git/commits{/sha}","comments_url":"https://api.github.com/repos/DrozdikGleb/Homework/comments{/number}","issue_comment_url":"https://api.github.com/repos/DrozdikGleb/Homework/issues/comments{/number}","contents_url":"https://api.github.com/repos/DrozdikGleb/Homework/contents/{+path}","compare_url":"https://api.github.com/repos/DrozdikGleb/Homework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DrozdikGleb/Homework/merges","archive_url":"https://api.github.com/repos/DrozdikGleb/Homework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DrozdikGleb/Homework/downloads","issues_url":"https://api.github.com/repos/DrozdikGleb/Homework/issues{/number}","pulls_url":"https://api.github.com/repos/DrozdikGleb/Homework/pulls{/number}","milestones_url":"https://api.github.com/repos/DrozdikGleb/Homework/milestones{/number}","notifications_url":"https://api.github.com/repos/DrozdikGleb/Homework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DrozdikGleb/Homework/labels{/name}","releases_url":"https://api.github.com/repos/DrozdikGleb/Homework/releases{/id}","deployments_url":"https://api.github.com/repos/DrozdikGleb/Homework/deployments","created_at":"2018-02-06T20:07:30Z","updated_at":"2018-02-06T20:07:31Z","pushed_at":"2018-02-26T13:13:20Z","git_url":"git://github.com/DrozdikGleb/Homework.git","ssh_url":"git@github.com:DrozdikGleb/Homework.git","clone_url":"https://github.com/DrozdikGleb/Homework.git","svn_url":"https://github.com/DrozdikGleb/Homework","homepage":null,"size":62,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"SberTechJavaSchool:Drozdov","ref":"Drozdov","sha":"0e50ce813625a829c70f4c7ae5fc97cb16f03657","user":{"login":"SberTechJavaSchool","id":36043895,"avatar_url":"https://avatars3.githubusercontent.com/u/36043895?v=4","gravatar_id":"","url":"https://api.github.com/users/SberTechJavaSchool","html_url":"https://github.com/SberTechJavaSchool","followers_url":"https://api.github.com/users/SberTechJavaSchool/followers","following_url":"https://api.github.com/users/SberTechJavaSchool/following{/other_user}","gists_url":"https://api.github.com/users/SberTechJavaSchool/gists{/gist_id}","starred_url":"https://api.github.com/users/SberTechJavaSchool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SberTechJavaSchool/subscriptions","organizations_url":"https://api.github.com/users/SberTechJavaSchool/orgs","repos_url":"https://api.github.com/users/SberTechJavaSchool/repos","events_url":"https://api.github.com/users/SberTechJavaSchool/events{/privacy}","received_events_url":"https://api.github.com/users/SberTechJavaSchool/received_events","type":"Organization","site_admin":false},"repo":{"id":120473051,"name":"Homework","full_name":"SberTechJavaSchool/Homework","owner":{"login":"SberTechJavaSchool","id":36043895,"avatar_url":"https://avatars3.githubusercontent.com/u/36043895?v=4","gravatar_id":"","url":"https://api.github.com/users/SberTechJavaSchool","html_url":"https://github.com/SberTechJavaSchool","followers_url":"https://api.github.com/users/SberTechJavaSchool/followers","following_url":"https://api.github.com/users/SberTechJavaSchool/following{/other_user}","gists_url":"https://api.github.com/users/SberTechJavaSchool/gists{/gist_id}","starred_url":"https://api.github.com/users/SberTechJavaSchool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SberTechJavaSchool/subscriptions","organizations_url":"https://api.github.com/users/SberTechJavaSchool/orgs","repos_url":"https://api.github.com/users/SberTechJavaSchool/repos","events_url":"https://api.github.com/users/SberTechJavaSchool/events{/privacy}","received_events_url":"https://api.github.com/users/SberTechJavaSchool/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SberTechJavaSchool/Homework","description":"Домашняя работа","fork":false,"url":"https://api.github.com/repos/SberTechJavaSchool/Homework","forks_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/forks","keys_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/teams","hooks_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/hooks","issue_events_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/issues/events{/number}","events_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/events","assignees_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/assignees{/user}","branches_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/branches{/branch}","tags_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/tags","blobs_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/git/refs{/sha}","trees_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/statuses/{sha}","languages_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/languages","stargazers_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/stargazers","contributors_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/contributors","subscribers_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/subscribers","subscription_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/subscription","commits_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/commits{/sha}","git_commits_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/git/commits{/sha}","comments_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/comments{/number}","issue_comment_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/issues/comments{/number}","contents_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/contents/{+path}","compare_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/merges","archive_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/downloads","issues_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/issues{/number}","pulls_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls{/number}","milestones_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/milestones{/number}","notifications_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/labels{/name}","releases_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/releases{/id}","deployments_url":"https://api.github.com/repos/SberTechJavaSchool/Homework/deployments","created_at":"2018-02-06T14:49:25Z","updated_at":"2018-02-23T12:56:05Z","pushed_at":"2018-03-01T11:10:03Z","git_url":"git://github.com/SberTechJavaSchool/Homework.git","ssh_url":"git@github.com:SberTechJavaSchool/Homework.git","clone_url":"https://github.com/SberTechJavaSchool/Homework.git","svn_url":"https://github.com/SberTechJavaSchool/Homework","homepage":null,"size":377,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":22,"mirror_url":null,"archived":false,"open_issues_count":22,"license":null,"forks":22,"open_issues":22,"watchers":4,"default_branch":"tasks"}},"_links":{"self":{"href":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/59"},"html":{"href":"https://github.com/SberTechJavaSchool/Homework/pull/59"},"issue":{"href":"https://api.github.com/repos/SberTechJavaSchool/Homework/issues/59"},"comments":{"href":"https://api.github.com/repos/SberTechJavaSchool/Homework/issues/59/comments"},"review_comments":{"href":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/59/comments"},"review_comment":{"href":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SberTechJavaSchool/Homework/pulls/59/commits"},"statuses":{"href":"https://api.github.com/repos/SberTechJavaSchool/Homework/statuses/14dcbd9ad1de9a155919ad0af91541d8c885105a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"bormoshka"}}