1 package org.hibernate; 3 4 import java.io.Serializable ; 5 import java.util.HashMap ; 6 import java.util.Map ; 7 8 16 public final class FlushMode implements Serializable { 17 private final int level; 18 private final String name; 19 private static final Map INSTANCES = new HashMap (); 20 21 private FlushMode(int level, String name) { 22 this.level=level; 23 this.name=name; 24 } 25 public String toString() { 26 return name; 27 } 28 33 public static final FlushMode NEVER = new FlushMode(0, "NEVER"); 34 38 public static final FlushMode COMMIT = new FlushMode(5, "COMMIT"); 39 44 public static final FlushMode AUTO = new FlushMode(10, "AUTO"); 45 49 public static final FlushMode ALWAYS = new FlushMode(20, "ALWAYS"); 50 51 public boolean lessThan(FlushMode other) { 52 return this.level<other.level; 53 } 54 55 static { 56 INSTANCES.put( NEVER.name, NEVER ); 57 INSTANCES.put( AUTO.name, AUTO ); 58 INSTANCES.put( ALWAYS.name, ALWAYS ); 59 INSTANCES.put( COMMIT.name, COMMIT ); 60 } 61 62 private Object readResolve() { 63 return INSTANCES.get(name); 64 } 65 66 } 67 68 69 70 71 72 73 | Popular Tags |