1 4 package com.tc.object.config; 5 6 import com.tc.object.lockmanager.api.LockLevel; 7 8 import java.util.Collections ; 9 import java.util.HashMap ; 10 import java.util.Map ; 11 12 public class ConfigLockLevel { 13 static final String WRITE_NAME = "write"; 14 static final String READ_NAME = "read"; 15 static final String CONCURRENT_NAME = "concurrent"; 16 static final String SYNCHRONOUS_WRITE_NAME = "synchronous-write"; 17 18 public static final ConfigLockLevel WRITE = new ConfigLockLevel(WRITE_NAME, LockLevel.WRITE); 19 public static final ConfigLockLevel READ = new ConfigLockLevel(READ_NAME, LockLevel.READ); 20 public static final ConfigLockLevel CONCURRENT = new ConfigLockLevel(CONCURRENT_NAME, LockLevel.CONCURRENT); 21 public static final ConfigLockLevel SYNCHRONOUS_WRITE = new ConfigLockLevel(SYNCHRONOUS_WRITE_NAME, 22 LockLevel.SYNCHRONOUS_WRITE); 23 24 private static final Map locksByLevel; 25 26 static { 27 HashMap tmp = new HashMap (); 28 29 tmp.put(WRITE_NAME, WRITE); 30 tmp.put(READ_NAME, READ); 31 tmp.put(CONCURRENT_NAME, CONCURRENT); 32 tmp.put(SYNCHRONOUS_WRITE_NAME, SYNCHRONOUS_WRITE); 33 34 locksByLevel = Collections.unmodifiableMap(tmp); 35 } 36 37 private final String lockLevelName; 38 private final int level; 39 40 private ConfigLockLevel(String lockTypeName, int type) { 41 this.lockLevelName = lockTypeName; 42 this.level = type; 43 } 44 45 public int getLevel() { 46 return level; 47 } 48 49 public String toString() { 50 return lockLevelName; 51 } 52 53 public static ConfigLockLevel lockLevelByName(String typeName) { 54 ConfigLockLevel rv = null; 55 if (typeName != null) rv = (ConfigLockLevel) locksByLevel.get(typeName); 56 return rv; 57 } 58 } 59 | Popular Tags |