1 package org.argosfields.persistence;
2
3 import net.sf.hibernate.PersistentEnum;
4
5 /***
6 * GameResult.java
7 *
8 * @author Xavier Cho
9 * @version $Revision: 1.1 $ $Date: 2004/04/15 05:43:55 $
10 */
11 public final class GameResult implements PersistentEnum {
12 public static final GameResult WIN = new GameResult(2);
13 public static final GameResult LOSE = new GameResult(1);
14 public static final GameResult DISCONNECTED = new GameResult(0);
15
16 private int code;
17
18 private GameResult(final int code) {
19 this.code = code;
20 }
21
22 /***
23 * @see net.sf.hibernate.PersistentEnum#toInt()
24 */
25 public int toInt() {
26 return code;
27 }
28
29 public static GameResult fromInt(final int code) {
30 switch (code) {
31 case 2 :
32 return WIN;
33 case 1 :
34 return LOSE;
35 case 0 :
36 return DISCONNECTED;
37 default :
38 String msg = "Invalid game result code : " + code;
39 throw new IllegalArgumentException(msg);
40 }
41 }
42 }
This page was automatically generated by Maven