Line | |
---|
1 | package geniusweb.progress;
|
---|
2 |
|
---|
3 | import java.util.Date;
|
---|
4 |
|
---|
5 | import geniusweb.deadline.Deadline;
|
---|
6 | import geniusweb.deadline.DeadlineRounds;
|
---|
7 | import geniusweb.deadline.DeadlineTime;
|
---|
8 |
|
---|
9 | public class ProgressFactory {
|
---|
10 | /**
|
---|
11 | *
|
---|
12 | * @param deadline the deadline to create a progress for
|
---|
13 | * @param nowms The time as from {@link System#currentTimeMillis()} that
|
---|
14 | * is to be used as start time for the progress.
|
---|
15 | * @return new Progress matching the deadline type.
|
---|
16 | */
|
---|
17 | public static Progress create(Deadline deadline, Long nowms) {
|
---|
18 | if (deadline instanceof DeadlineRounds) {
|
---|
19 | return new ProgressRounds(((DeadlineRounds) deadline).getRounds(),
|
---|
20 | 0, new Date(
|
---|
21 | nowms + ((DeadlineRounds) deadline).getDuration()));
|
---|
22 | } else {
|
---|
23 | return new ProgressTime(((DeadlineTime) deadline).getDuration(),
|
---|
24 | new Date(nowms));
|
---|
25 | }
|
---|
26 |
|
---|
27 | }
|
---|
28 |
|
---|
29 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.