NotSpecification.java 583B

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