1 package se.citerus.dddsample.domain.shared; 2 3 /** 4 * NOT decorator, used to create a new specifcation that is the inverse (NOT) of the given spec. 5 */ 6 public class NotSpecification<T> extends AbstractSpecification<T> { 7 8 private Specification<T> spec1; 9 10 /** 11 * Create a new NOT specification based on another spec. 12 * 13 * @param spec1 Specification instance to not. 14 */ 15 public NotSpecification(final Specification<T> spec1) { 16 this.spec1 = spec1; 17 } 18 19 /** 20 * {@inheritDoc} 21 */ 22 public boolean isSatisfiedBy(final T t) { 23 return !spec1.isSatisfiedBy(t); 24 } 25 }