{"action":"created","comment":{"url":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/comments/59425818","id":59425818,"diff_hunk":"@@ -0,0 +1,144 @@\n+package org.optaplanner.core.impl.domain.valuerange.buildin.temporal;\n+\n+import org.optaplanner.core.impl.domain.valuerange.AbstractCountableValueRange;\n+import org.optaplanner.core.impl.domain.valuerange.util.ValueRangeIterator;\n+import org.optaplanner.core.impl.solver.random.RandomUtils;\n+\n+import java.time.temporal.Temporal;\n+import java.time.temporal.TemporalUnit;\n+import java.util.Iterator;\n+import java.util.NoSuchElementException;\n+import java.util.Random;\n+\n+/**\n+ * Created by kevin on 08.04.2016.\n+ */\n+public class TemporalValueRange extends AbstractCountableValueRange<Temporal> {\n+\n+    private final Temporal from;\n+    private final Temporal to;\n+    private final long incrementAmount;\n+    private final TemporalUnit incrementUnit;\n+\n+    /**\n+     * @param from inclusive minimum\n+     * @param to exclusive maximum, {@code >= from}\n+     * @param incrementAmount {@code > 0}\n+     * @param incrementUnit depends on the supported units of {from} and {to}\n+     */\n+    public TemporalValueRange(Temporal from, Temporal to, long incrementAmount, TemporalUnit incrementUnit) {\n+        this.from = from;\n+        this.to = to;\n+        this.incrementAmount = incrementAmount;\n+        this.incrementUnit = incrementUnit;\n+\n+        if (from == null || to == null || incrementUnit == null) {\n+            throw new IllegalArgumentException(\"The \" + getClass().getSimpleName()\n+                    + \" must have from (\" + from + \"),  to (\" + to + \"), incrementUnit (\" + incrementUnit + \") which are not null.\");\n+        }\n+\n+        if (incrementAmount <= 0) {\n+            throw new IllegalArgumentException(\"The \" + getClass().getSimpleName()\n+                    + \" must have strictly positive incrementAmount (\" + incrementAmount + \").\");\n+        }\n+\n+        if (!from.isSupported(incrementUnit) || !to.isSupported(incrementUnit)) {\n+            throw new IllegalArgumentException(\"The \" + getClass().getSimpleName()\n+                    + \" must have a incrementUnit which is supported by from/to (\" + incrementUnit + \").\");\n+        }\n+\n+        if (from.until(to, incrementUnit) < 0) {\n+            throw new IllegalArgumentException(\"The \" + getClass().getSimpleName()\n+                    + \" cannot have a from (\" + from + \") which is strictly higher than its to (\" + to + \").\");\n+        }\n+\n+\n+    }\n+\n+    private long getDuration() {\n+        return from.until(to, incrementUnit);\n+    }\n+\n+    @Override\n+    public long getSize() {\n+        return (getDuration() / incrementAmount);\n+    }\n+\n+    @Override\n+    public Temporal get(long index) {\n+        if (index >= getSize() || index < 0) {\n+            throw new IndexOutOfBoundsException();\n+        }\n+        return from.plus(index * incrementAmount, incrementUnit);\n+    }\n+\n+    @Override\n+    public Iterator<Temporal> createOriginalIterator() {\n+        return new OriginalTemporalValueRangeIterator();\n+    }\n+\n+    private class OriginalTemporalValueRangeIterator extends ValueRangeIterator<Temporal> {\n+\n+        private Temporal upcoming = from;\n+\n+        @Override\n+        public boolean hasNext() {\n+            return upcoming.until(to, incrementUnit) >= incrementAmount;\n+        }\n+\n+        @Override\n+        public Temporal next() {\n+            if (upcoming.until(to, incrementUnit) < 0) {\n+                throw new NoSuchElementException();\n+            }\n+\n+            Temporal next = upcoming;\n+            upcoming = upcoming.plus(incrementAmount, incrementUnit);","path":"optaplanner-core/src/main/java/org/optaplanner/core/impl/domain/valuerange/buildin/temporal/TemporalValueRange.java","position":96,"original_position":96,"commit_id":"dd109b776e2bc1a09177176b24c92922e86ec10c","original_commit_id":"dd109b776e2bc1a09177176b24c92922e86ec10c","user":{"login":"Blackjack92","id":11227428,"avatar_url":"https://avatars.githubusercontent.com/u/11227428?v=3","gravatar_id":"","url":"https://api.github.com/users/Blackjack92","html_url":"https://github.com/Blackjack92","followers_url":"https://api.github.com/users/Blackjack92/followers","following_url":"https://api.github.com/users/Blackjack92/following{/other_user}","gists_url":"https://api.github.com/users/Blackjack92/gists{/gist_id}","starred_url":"https://api.github.com/users/Blackjack92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Blackjack92/subscriptions","organizations_url":"https://api.github.com/users/Blackjack92/orgs","repos_url":"https://api.github.com/users/Blackjack92/repos","events_url":"https://api.github.com/users/Blackjack92/events{/privacy}","received_events_url":"https://api.github.com/users/Blackjack92/received_events","type":"User","site_admin":false},"body":"Okay very good code changes :+1: , i have not recognized this bug while implementing :/\r\nWhy do you use the generic Temporal_?\r\n","created_at":"2016-04-12T18:14:54Z","updated_at":"2016-04-12T18:14:54Z","html_url":"https://github.com/droolsjbpm/optaplanner/pull/186#discussion_r59425818","pull_request_url":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/186","_links":{"self":{"href":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/comments/59425818"},"html":{"href":"https://github.com/droolsjbpm/optaplanner/pull/186#discussion_r59425818"},"pull_request":{"href":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/186"}}},"pull_request":{"url":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/186","id":65906939,"html_url":"https://github.com/droolsjbpm/optaplanner/pull/186","diff_url":"https://github.com/droolsjbpm/optaplanner/pull/186.diff","patch_url":"https://github.com/droolsjbpm/optaplanner/pull/186.patch","issue_url":"https://api.github.com/repos/droolsjbpm/optaplanner/issues/186","number":186,"state":"closed","locked":false,"title":"Ticket #549 TemporalValueRange added with tests","user":{"login":"Blackjack92","id":11227428,"avatar_url":"https://avatars.githubusercontent.com/u/11227428?v=3","gravatar_id":"","url":"https://api.github.com/users/Blackjack92","html_url":"https://github.com/Blackjack92","followers_url":"https://api.github.com/users/Blackjack92/followers","following_url":"https://api.github.com/users/Blackjack92/following{/other_user}","gists_url":"https://api.github.com/users/Blackjack92/gists{/gist_id}","starred_url":"https://api.github.com/users/Blackjack92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Blackjack92/subscriptions","organizations_url":"https://api.github.com/users/Blackjack92/orgs","repos_url":"https://api.github.com/users/Blackjack92/repos","events_url":"https://api.github.com/users/Blackjack92/events{/privacy}","received_events_url":"https://api.github.com/users/Blackjack92/received_events","type":"User","site_admin":false},"body":"The `contains` method should be improved when possible.","created_at":"2016-04-10T10:36:53Z","updated_at":"2016-04-12T18:14:54Z","closed_at":"2016-04-11T07:03:33Z","merged_at":"2016-04-11T07:03:33Z","merge_commit_sha":"bda3f32793e259fc0697d5f2c408a4f3392425f8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/186/commits","review_comments_url":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/186/comments","review_comment_url":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/droolsjbpm/optaplanner/issues/186/comments","statuses_url":"https://api.github.com/repos/droolsjbpm/optaplanner/statuses/dd109b776e2bc1a09177176b24c92922e86ec10c","head":{"label":"Blackjack92:PLANNER-549_Temporal","ref":"PLANNER-549_Temporal","sha":"dd109b776e2bc1a09177176b24c92922e86ec10c","user":{"login":"Blackjack92","id":11227428,"avatar_url":"https://avatars.githubusercontent.com/u/11227428?v=3","gravatar_id":"","url":"https://api.github.com/users/Blackjack92","html_url":"https://github.com/Blackjack92","followers_url":"https://api.github.com/users/Blackjack92/followers","following_url":"https://api.github.com/users/Blackjack92/following{/other_user}","gists_url":"https://api.github.com/users/Blackjack92/gists{/gist_id}","starred_url":"https://api.github.com/users/Blackjack92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Blackjack92/subscriptions","organizations_url":"https://api.github.com/users/Blackjack92/orgs","repos_url":"https://api.github.com/users/Blackjack92/repos","events_url":"https://api.github.com/users/Blackjack92/events{/privacy}","received_events_url":"https://api.github.com/users/Blackjack92/received_events","type":"User","site_admin":false},"repo":{"id":55787317,"name":"optaplanner","full_name":"Blackjack92/optaplanner","owner":{"login":"Blackjack92","id":11227428,"avatar_url":"https://avatars.githubusercontent.com/u/11227428?v=3","gravatar_id":"","url":"https://api.github.com/users/Blackjack92","html_url":"https://github.com/Blackjack92","followers_url":"https://api.github.com/users/Blackjack92/followers","following_url":"https://api.github.com/users/Blackjack92/following{/other_user}","gists_url":"https://api.github.com/users/Blackjack92/gists{/gist_id}","starred_url":"https://api.github.com/users/Blackjack92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Blackjack92/subscriptions","organizations_url":"https://api.github.com/users/Blackjack92/orgs","repos_url":"https://api.github.com/users/Blackjack92/repos","events_url":"https://api.github.com/users/Blackjack92/events{/privacy}","received_events_url":"https://api.github.com/users/Blackjack92/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Blackjack92/optaplanner","description":"Java planning engine: OptaPlanner optimizes business resource scheduling and planning.","fork":true,"url":"https://api.github.com/repos/Blackjack92/optaplanner","forks_url":"https://api.github.com/repos/Blackjack92/optaplanner/forks","keys_url":"https://api.github.com/repos/Blackjack92/optaplanner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Blackjack92/optaplanner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Blackjack92/optaplanner/teams","hooks_url":"https://api.github.com/repos/Blackjack92/optaplanner/hooks","issue_events_url":"https://api.github.com/repos/Blackjack92/optaplanner/issues/events{/number}","events_url":"https://api.github.com/repos/Blackjack92/optaplanner/events","assignees_url":"https://api.github.com/repos/Blackjack92/optaplanner/assignees{/user}","branches_url":"https://api.github.com/repos/Blackjack92/optaplanner/branches{/branch}","tags_url":"https://api.github.com/repos/Blackjack92/optaplanner/tags","blobs_url":"https://api.github.com/repos/Blackjack92/optaplanner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Blackjack92/optaplanner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Blackjack92/optaplanner/git/refs{/sha}","trees_url":"https://api.github.com/repos/Blackjack92/optaplanner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Blackjack92/optaplanner/statuses/{sha}","languages_url":"https://api.github.com/repos/Blackjack92/optaplanner/languages","stargazers_url":"https://api.github.com/repos/Blackjack92/optaplanner/stargazers","contributors_url":"https://api.github.com/repos/Blackjack92/optaplanner/contributors","subscribers_url":"https://api.github.com/repos/Blackjack92/optaplanner/subscribers","subscription_url":"https://api.github.com/repos/Blackjack92/optaplanner/subscription","commits_url":"https://api.github.com/repos/Blackjack92/optaplanner/commits{/sha}","git_commits_url":"https://api.github.com/repos/Blackjack92/optaplanner/git/commits{/sha}","comments_url":"https://api.github.com/repos/Blackjack92/optaplanner/comments{/number}","issue_comment_url":"https://api.github.com/repos/Blackjack92/optaplanner/issues/comments{/number}","contents_url":"https://api.github.com/repos/Blackjack92/optaplanner/contents/{+path}","compare_url":"https://api.github.com/repos/Blackjack92/optaplanner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Blackjack92/optaplanner/merges","archive_url":"https://api.github.com/repos/Blackjack92/optaplanner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Blackjack92/optaplanner/downloads","issues_url":"https://api.github.com/repos/Blackjack92/optaplanner/issues{/number}","pulls_url":"https://api.github.com/repos/Blackjack92/optaplanner/pulls{/number}","milestones_url":"https://api.github.com/repos/Blackjack92/optaplanner/milestones{/number}","notifications_url":"https://api.github.com/repos/Blackjack92/optaplanner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Blackjack92/optaplanner/labels{/name}","releases_url":"https://api.github.com/repos/Blackjack92/optaplanner/releases{/id}","deployments_url":"https://api.github.com/repos/Blackjack92/optaplanner/deployments","created_at":"2016-04-08T14:59:17Z","updated_at":"2016-04-08T14:59:32Z","pushed_at":"2016-04-10T10:34:01Z","git_url":"git://github.com/Blackjack92/optaplanner.git","ssh_url":"git@github.com:Blackjack92/optaplanner.git","clone_url":"https://github.com/Blackjack92/optaplanner.git","svn_url":"https://github.com/Blackjack92/optaplanner","homepage":"http://www.optaplanner.org","size":151561,"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":"droolsjbpm:master","ref":"master","sha":"ab1ceec3282d229e727dbbad1526c588cf2dde03","user":{"login":"droolsjbpm","id":517980,"avatar_url":"https://avatars.githubusercontent.com/u/517980?v=3","gravatar_id":"","url":"https://api.github.com/users/droolsjbpm","html_url":"https://github.com/droolsjbpm","followers_url":"https://api.github.com/users/droolsjbpm/followers","following_url":"https://api.github.com/users/droolsjbpm/following{/other_user}","gists_url":"https://api.github.com/users/droolsjbpm/gists{/gist_id}","starred_url":"https://api.github.com/users/droolsjbpm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/droolsjbpm/subscriptions","organizations_url":"https://api.github.com/users/droolsjbpm/orgs","repos_url":"https://api.github.com/users/droolsjbpm/repos","events_url":"https://api.github.com/users/droolsjbpm/events{/privacy}","received_events_url":"https://api.github.com/users/droolsjbpm/received_events","type":"Organization","site_admin":false},"repo":{"id":1370858,"name":"optaplanner","full_name":"droolsjbpm/optaplanner","owner":{"login":"droolsjbpm","id":517980,"avatar_url":"https://avatars.githubusercontent.com/u/517980?v=3","gravatar_id":"","url":"https://api.github.com/users/droolsjbpm","html_url":"https://github.com/droolsjbpm","followers_url":"https://api.github.com/users/droolsjbpm/followers","following_url":"https://api.github.com/users/droolsjbpm/following{/other_user}","gists_url":"https://api.github.com/users/droolsjbpm/gists{/gist_id}","starred_url":"https://api.github.com/users/droolsjbpm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/droolsjbpm/subscriptions","organizations_url":"https://api.github.com/users/droolsjbpm/orgs","repos_url":"https://api.github.com/users/droolsjbpm/repos","events_url":"https://api.github.com/users/droolsjbpm/events{/privacy}","received_events_url":"https://api.github.com/users/droolsjbpm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/droolsjbpm/optaplanner","description":"Java planning engine: OptaPlanner optimizes business resource scheduling and planning.","fork":false,"url":"https://api.github.com/repos/droolsjbpm/optaplanner","forks_url":"https://api.github.com/repos/droolsjbpm/optaplanner/forks","keys_url":"https://api.github.com/repos/droolsjbpm/optaplanner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/droolsjbpm/optaplanner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/droolsjbpm/optaplanner/teams","hooks_url":"https://api.github.com/repos/droolsjbpm/optaplanner/hooks","issue_events_url":"https://api.github.com/repos/droolsjbpm/optaplanner/issues/events{/number}","events_url":"https://api.github.com/repos/droolsjbpm/optaplanner/events","assignees_url":"https://api.github.com/repos/droolsjbpm/optaplanner/assignees{/user}","branches_url":"https://api.github.com/repos/droolsjbpm/optaplanner/branches{/branch}","tags_url":"https://api.github.com/repos/droolsjbpm/optaplanner/tags","blobs_url":"https://api.github.com/repos/droolsjbpm/optaplanner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/droolsjbpm/optaplanner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/droolsjbpm/optaplanner/git/refs{/sha}","trees_url":"https://api.github.com/repos/droolsjbpm/optaplanner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/droolsjbpm/optaplanner/statuses/{sha}","languages_url":"https://api.github.com/repos/droolsjbpm/optaplanner/languages","stargazers_url":"https://api.github.com/repos/droolsjbpm/optaplanner/stargazers","contributors_url":"https://api.github.com/repos/droolsjbpm/optaplanner/contributors","subscribers_url":"https://api.github.com/repos/droolsjbpm/optaplanner/subscribers","subscription_url":"https://api.github.com/repos/droolsjbpm/optaplanner/subscription","commits_url":"https://api.github.com/repos/droolsjbpm/optaplanner/commits{/sha}","git_commits_url":"https://api.github.com/repos/droolsjbpm/optaplanner/git/commits{/sha}","comments_url":"https://api.github.com/repos/droolsjbpm/optaplanner/comments{/number}","issue_comment_url":"https://api.github.com/repos/droolsjbpm/optaplanner/issues/comments{/number}","contents_url":"https://api.github.com/repos/droolsjbpm/optaplanner/contents/{+path}","compare_url":"https://api.github.com/repos/droolsjbpm/optaplanner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/droolsjbpm/optaplanner/merges","archive_url":"https://api.github.com/repos/droolsjbpm/optaplanner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/droolsjbpm/optaplanner/downloads","issues_url":"https://api.github.com/repos/droolsjbpm/optaplanner/issues{/number}","pulls_url":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls{/number}","milestones_url":"https://api.github.com/repos/droolsjbpm/optaplanner/milestones{/number}","notifications_url":"https://api.github.com/repos/droolsjbpm/optaplanner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/droolsjbpm/optaplanner/labels{/name}","releases_url":"https://api.github.com/repos/droolsjbpm/optaplanner/releases{/id}","deployments_url":"https://api.github.com/repos/droolsjbpm/optaplanner/deployments","created_at":"2011-02-15T19:38:23Z","updated_at":"2016-04-12T09:44:28Z","pushed_at":"2016-04-12T16:45:09Z","git_url":"git://github.com/droolsjbpm/optaplanner.git","ssh_url":"git@github.com:droolsjbpm/optaplanner.git","clone_url":"https://github.com/droolsjbpm/optaplanner.git","svn_url":"https://github.com/droolsjbpm/optaplanner","homepage":"http://www.optaplanner.org","size":154045,"stargazers_count":379,"watchers_count":379,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":252,"mirror_url":null,"open_issues_count":4,"forks":252,"open_issues":4,"watchers":379,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/186"},"html":{"href":"https://github.com/droolsjbpm/optaplanner/pull/186"},"issue":{"href":"https://api.github.com/repos/droolsjbpm/optaplanner/issues/186"},"comments":{"href":"https://api.github.com/repos/droolsjbpm/optaplanner/issues/186/comments"},"review_comments":{"href":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/186/comments"},"review_comment":{"href":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/droolsjbpm/optaplanner/pulls/186/commits"},"statuses":{"href":"https://api.github.com/repos/droolsjbpm/optaplanner/statuses/dd109b776e2bc1a09177176b24c92922e86ec10c"}}}}