1 package org.argosfields.model;
2
3 /***
4 * Direction.java
5 *
6 * @author Xavier Cho
7 * @version $Revision: 1.3 $ $Date: 2003/12/01 07:38:05 $
8 */
9 public final class Direction {
10 public static final Direction NORTH = new Direction(0);
11 public static final Direction NORTHEAST = new Direction(1);
12 public static final Direction SOUTHEAST = new Direction(2);
13 public static final Direction SOUTH = new Direction(3);
14 public static final Direction SOUTHWEST = new Direction(4);
15 public static final Direction NORTHWEST = new Direction(5);
16
17 private int code;
18
19 private Direction(final int code) {
20 this.code = code;
21 }
22
23 public int toInt() {
24 return code;
25 }
26
27 public static Direction fromInt(final int code) {
28 Direction direction;
29
30 switch (code) {
31 case 0:
32 direction = NORTH;
33 break;
34 case 1:
35 direction = NORTHEAST;
36 break;
37 case 2:
38 direction = SOUTHEAST;
39 break;
40 case 3:
41 direction = SOUTH;
42 break;
43 case 4:
44 direction = SOUTHWEST;
45 break;
46 case 5:
47 direction = NORTHWEST;
48 break;
49 default:
50 direction = null;
51 }
52
53 return direction;
54 }
55 }
This page was automatically generated by Maven