1 package se.citerus.dddsample.domain.shared; 2 3 /** 4 * OR specification, used to create a new specifcation that is the OR of two other specifications. 5 */ 6 public class OrSpecification<T> extends AbstractSpecification<T> { 7 8 private Specification<T> spec1; 9 private Specification<T> spec2; 10 11 /** 12 * Create a new OR specification based on two other spec. 13 * 14 * @param spec1 Specification one. 15 * @param spec2 Specification two. 16 */ 17 public OrSpecification(final Specification<T> spec1, final Specification<T> spec2) { 18 this.spec1 = spec1; 19 this.spec2 = spec2; 20 } 21 22 /** 23 * {@inheritDoc} 24 */ 25 public boolean isSatisfiedBy(final T t) { 26 return spec1.isSatisfiedBy(t) || spec2.isSatisfiedBy(t); 27 } 28 }