1 package jfun.yan.xml; 2 3 final class FilteringRegistry implements Registry { 4 private final Registry reg; 5 private final StringPredicate filter; 6 7 public FilteringRegistry(StringPredicate filter, Registry reg) { 8 this.filter = filter; 9 this.reg = reg; 10 } 11 public void put(String key, Object val, Location loc) { 12 if(filter.isString(key)){ 13 reg.put(key, val, loc); 14 } 15 } 16 public boolean equals(Object obj) { 17 if(obj instanceof FilteringRegistry){ 18 final FilteringRegistry other = (FilteringRegistry)obj; 19 return reg.equals(other.reg) && filter.equals(other.filter); 20 } 21 return false; 22 } 23 public int hashCode() { 24 return filter.hashCode()*31+reg.hashCode(); 25 } 26 public String toString() { 27 return filter.toString(); 28 } 29 30 } 31 | Popular Tags |