1 7 package org.jboss.cache.eviction; 8 9 import org.jboss.cache.config.ConfigurationException; 10 import org.jboss.cache.config.Dynamic; 11 12 31 public class ElementSizeConfiguration extends EvictionPolicyConfigBase 32 { 33 34 private static final long serialVersionUID = 2510593544656833758L; 35 36 @Dynamic 37 private int maxElementsPerNode; 38 39 public ElementSizeConfiguration() 40 { 41 setEvictionPolicyClassName(); 42 setMaxElementsPerNode(-1); 44 } 45 46 @Override 47 protected void setEvictionPolicyClassName() 48 { 49 setEvictionPolicyClass(ElementSizePolicy.class.getName()); 50 } 51 52 public int getMaxElementsPerNode() 53 { 54 return maxElementsPerNode; 55 } 56 57 public void setMaxElementsPerNode(int maxElementsPerNode) 58 { 59 testImmutability("maxElementsPerNode"); 60 this.maxElementsPerNode = maxElementsPerNode; 61 } 62 63 67 @Override 68 public void validate() throws ConfigurationException 69 { 70 if (maxElementsPerNode < 0) throw new ConfigurationException("maxElementsPerNode must be configured"); 71 } 72 73 public String toString() 74 { 75 StringBuffer str = new StringBuffer (); 76 str.append("ElementSizeConfiguration: maxElementsPerNode ="); 77 str.append(getMaxElementsPerNode()).append(" maxNodes =").append(getMaxNodes()); 78 return str.toString(); 79 } 80 81 @Override 82 public boolean equals(Object obj) 83 { 84 if (this == obj) 85 return true; 86 if (obj instanceof ElementSizeConfiguration && super.equals(obj)) 87 { 88 return this.maxElementsPerNode == ((ElementSizeConfiguration) obj).maxElementsPerNode; 89 } 90 return false; 91 } 92 93 @Override 94 public int hashCode() 95 { 96 int result = super.hashCode(); 97 result = 31 * result + maxElementsPerNode; 98 return result; 99 } 100 101 @Override 102 public void reset() 103 { 104 super.reset(); 105 setMaxElementsPerNode(-1); 106 } 107 } 108 | Popular Tags |