1 package org.hibernate; 3 4 import java.io.Serializable ; 5 import java.util.HashMap ; 6 import java.util.Map ; 7 8 15 public final class CacheMode implements Serializable { 16 private final String name; 17 private final boolean isPutEnabled; 18 private final boolean isGetEnabled; 19 private static final Map INSTANCES = new HashMap (); 20 21 private CacheMode(String name, boolean isPutEnabled, boolean isGetEnabled) { 22 this.name=name; 23 this.isPutEnabled = isPutEnabled; 24 this.isGetEnabled = isGetEnabled; 25 } 26 public String toString() { 27 return name; 28 } 29 public boolean isPutEnabled() { 30 return isPutEnabled; 31 } 32 public boolean isGetEnabled() { 33 return isGetEnabled; 34 } 35 38 public static final CacheMode NORMAL = new CacheMode("NORMAL", true, true); 39 43 public static final CacheMode IGNORE = new CacheMode("IGNORE", false, false); 44 48 public static final CacheMode GET = new CacheMode("GET", false, true); 49 53 public static final CacheMode PUT = new CacheMode("PUT", true, false); 54 55 61 public static final CacheMode REFRESH = new CacheMode("REFRESH", true, false); 62 63 static { 64 INSTANCES.put( NORMAL.name, NORMAL ); 65 INSTANCES.put( IGNORE.name, IGNORE ); 66 INSTANCES.put( GET.name, GET ); 67 INSTANCES.put( PUT.name, PUT ); 68 INSTANCES.put( REFRESH.name, REFRESH ); 69 } 70 71 private Object readResolve() { 72 return INSTANCES.get(name); 73 } 74 75 } 76 77 78 79 80 81 82 | Popular Tags |