Mercurial > hg > Database > Alice
view src/alice/datasegment/CommandType.java @ 184:4475ba30238f working
minor change
author | e095732 |
---|---|
date | Wed, 27 Feb 2013 06:30:14 +0900 |
parents | 7fa9ddb31f64 |
children | 7f47231ef509 |
line wrap: on
line source
package alice.datasegment; import java.util.HashMap; public enum CommandType { PUT, UPDATE, // remove a DataSegment value and put PEEK, TAKE, REMOVE, REPLY, CLOSE, FINISH, FLIP; public int id; public static HashMap<Integer, CommandType> hash = new HashMap<Integer, CommandType>(); private static int lastId = 0; private CommandType(int id) { this.id = id; setLastId(id); } private CommandType() { this.id = incrementLastId(); } private void setLastId(int id) { lastId =id; } private int incrementLastId() { return ++lastId; } public static CommandType getCommandTypeFromId(int id) { return hash.get(id); } static { for (CommandType type : CommandType.values()) { hash.put(type.id, type); } } }