1 package jfun.yan.etc; 2 3 import jfun.yan.Creator; 4 import jfun.yan.PropertyBinder; 5 6 14 public class FilteredPropertyBinder implements PropertyBinder { 15 private final PropertyBinder alternative; 16 private final PropertyPredicate pred; 17 private final Creator consequence; 18 public Creator bind(Class component_type, Object key, Class type) { 19 if(pred.isProperty(component_type, key, type)){ 20 return consequence; 21 } 22 else{ 23 return alternative.bind(component_type, key, type); 24 } 25 } 26 32 public FilteredPropertyBinder(PropertyPredicate pred, 33 Creator consequence, PropertyBinder alternative) { 34 this.pred = pred; 35 this.consequence = consequence; 36 this.alternative = alternative; 37 } 38 } 39 | Popular Tags |