BrightSide Workbench Full Report + Source Code
BrightSide/bserp-core/src/main/java/org/turro/erp/entity/TaskStatus.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.erp.entity;
19 
20 import java.util.EnumSet;
21 
26 public enum TaskStatus {
27 
29  TASK_READY(1, 1),
30  TASK_ONWORK(0, 2),
32 
33  private int workOrder, statusOrder;
34 
35  private TaskStatus(int workOrder, int statusOrder) {
36  this.workOrder = workOrder;
37  this.statusOrder = statusOrder;
38  }
39 
40  public int getStatusOrder() {
41  return statusOrder;
42  }
43 
44  public int getWorkOrder() {
45  return workOrder;
46  }
47 
48  public EnumSet<TaskStatus> getPossibleStatus() {
49  EnumSet<TaskStatus> statusSet = EnumSet.of(this);
50  for(TaskStatus ts : values()) {
51  if(ts.statusOrder > statusOrder) {
52  statusSet.add(ts);
53  }
54  }
55  return statusSet;
56  }
57 
58  public static boolean isReady(TaskStatus status) {
59  return EnumSet.of(TASK_READY).contains(status);
60  }
61 
62  public static boolean isOnWork(TaskStatus status) {
63  return EnumSet.of(TASK_READY, TASK_ONWORK).contains(status);
64  }
65 
66  public static boolean hasStarted(TaskStatus status) {
67  return EnumSet.of(TASK_READY, TASK_ONWORK, TASK_FINISHED).contains(status);
68  }
69 
70  public static boolean isFinished(TaskStatus status) {
71  return EnumSet.of(TASK_FINISHED).contains(status);
72  }
73 
74 }