1 package com.thoughtworks.acceptance.objects; 2 3 import java.io.ObjectStreamException ; 4 import java.io.Serializable ; 5 import java.util.Arrays ; 6 import java.util.Collections ; 7 import java.util.List ; 8 9 public class StatusEnum implements Serializable , Comparable { 10 11 private static int nextOrdinal = 0; 12 private int ordinal = nextOrdinal++; 13 14 public static final StatusEnum STARTED = new StatusEnum("STARTED"); 15 16 public static final StatusEnum FINISHED = new StatusEnum("FINISHED"); 17 18 private static final StatusEnum[] PRIVATE_VALUES = {STARTED, FINISHED}; 19 20 public static final List VALUES = Collections.unmodifiableList(Arrays.asList(PRIVATE_VALUES)); 21 22 private String name; 24 private StatusEnum() { 25 } 26 27 private StatusEnum(String name) { 28 this.name = name; 29 } 30 31 public String toString() { 32 return name; 33 } 34 35 public int compareTo(Object o) { 36 return ordinal - ((StatusEnum) o).ordinal; 37 } 38 39 private Object readResolve() throws ObjectStreamException { 40 return PRIVATE_VALUES[ordinal]; } 42 } 43 | Popular Tags |