1 16 17 package com.google.inject.matcher; 18 19 24 public abstract class AbstractMatcher<T> implements Matcher<T> { 25 26 public Matcher<T> and(final Matcher<? super T> other) { 27 return new AndMatcher<T>(this, other); 28 } 29 30 public Matcher<T> or(Matcher<? super T> other) { 31 return new OrMatcher<T>(this, other); 32 } 33 34 static class AndMatcher<T> extends AbstractMatcher<T> { 35 36 final Matcher<? super T> a, b; 37 38 public AndMatcher(Matcher<? super T> a, Matcher<? super T> b) { 39 this.a = a; 40 this.b = b; 41 } 42 43 public boolean matches(T t) { 44 return a.matches(t) && b.matches(t); 45 } 46 } 47 48 static class OrMatcher<T> extends AbstractMatcher<T> { 49 50 final Matcher<? super T> a, b; 51 52 public OrMatcher(Matcher<? super T> a, Matcher<? super T> b) { 53 this.a = a; 54 this.b = b; 55 } 56 57 public boolean matches(T t) { 58 return a.matches(t) || b.matches(t); 59 } 60 } 61 } 62 | Popular Tags |