korhan-Ö
11/14/2017 - 6:34 AM

Enum Kullanımı

public static enum TaskState {
		NOT_STARTED(1, MarkerType.Blue),
		ON_GOING(2, MarkerType.Green),
		FINISHED(3, MarkerType.Yellow),
		NOT_COMPLETED(4, MarkerType.Red);
		private int        value;
		private MarkerType type;

		private TaskState(int value, MarkerType type) {
			this.value = value;
			this.type = type;
		}

		public static TaskState getTaskStateFromValue(int value) {
			for (TaskState taskState : TaskState.values()) {
				if (taskState.value == value) {
					return taskState;
				}
			}
			return NOT_STARTED;
		}

		public int getTaskStateValue() {
			return this.value;
		}

		public MarkerType getMarkerType() {
			return this.type;
		}
	}