1 package org.jboss.cache.eviction; 2 3 import org.jboss.cache.config.ConfigurationComponent; 4 import org.jboss.cache.config.ConfigurationException; 5 import org.jboss.cache.config.Dynamic; 6 7 13 public abstract class EvictionPolicyConfigBase 14 extends ConfigurationComponent 15 implements EvictionPolicyConfig 16 { 17 18 private static final long serialVersionUID = 4591691674370188932L; 19 20 private String evictionPolicyClass; 21 @Dynamic 22 private int maxNodes = 0; 23 24 28 protected EvictionPolicyConfigBase() {} 29 30 public String getEvictionPolicyClass() 31 { 32 return evictionPolicyClass; 33 } 34 35 public void setEvictionPolicyClass(String evictionPolicyClass) 36 { 37 testImmutability("evictionPolicyClass"); 38 this.evictionPolicyClass = evictionPolicyClass; 39 } 40 41 public int getMaxNodes() 42 { 43 return maxNodes; 44 } 45 46 public void setMaxNodes(int maxNodes) 47 { 48 testImmutability("maxNodes"); 49 this.maxNodes = maxNodes; 50 } 51 52 public void validate() throws ConfigurationException 53 { 54 } 56 57 @Override 58 public boolean equals(Object obj) 59 { 60 if (this == obj) 61 return true; 62 63 if (obj instanceof EvictionPolicyConfigBase) 64 { 65 EvictionPolicyConfigBase other = (EvictionPolicyConfigBase) obj; 66 67 return this.maxNodes == other.maxNodes 68 && safeEquals(this.evictionPolicyClass, other.evictionPolicyClass); 69 } 70 71 return false; 72 } 73 74 @Override 75 public int hashCode() 76 { 77 int result = 17; 78 result = 31 * result + maxNodes; 79 result = 31 * result + (evictionPolicyClass == null ? 0 : evictionPolicyClass.hashCode()); 80 return result; 81 } 82 83 public void reset() 84 { 85 setEvictionPolicyClass(null); 86 setMaxNodes(0); 87 setEvictionPolicyClassName(); 88 } 89 90 95 abstract protected void setEvictionPolicyClassName(); 96 } 97 | Popular Tags |