InstanceFilter、ExceptionTypeFilter

InstanceFilter

一个简单的匹配器,子类可以覆盖match方法自定义match规则

 

private final Collection<? extends T> includes;

private final Collection<? extends T> excludes;

private final boolean matchIfEmpty;

 

#public boolean match(T instance)  检查是否 在包含范围但不在排除范围

  ##若includes和excludes都为空 -> return this.matchIfEmpty;  按matchIfEmpty

  ##若includes为空 -> return !matchExcludes;  不在excludes中

  ##若excludes为空 -> return matchIncludes;  在includes中

  ##return matchIncludes && !matchExcludes;  在includes中且不在excludes中

#protected boolean match(T instance, T candidate)  return instance.equals(candidate);

#protected boolean match(T instance, Collection<? extends T> candidates)   与candidates中的逐个匹配

 

ExceptionTypeFilter

覆盖了父类的match(T instance, T candidate)  

#protected boolean match(Class<? extends Throwable> instance, Class<? extends Throwable> candidate)  return candidate.isAssignableFrom(instance);

 

 

posted on 2021-10-15 16:48  icodegarden  阅读(25)  评论(0编辑  收藏  举报