View Javadoc

1   package se.citerus.dddsample.domain.shared;
2   
3   
4   /**
5    * Abstract base implementation of composite {@link Specification} with default
6    * implementations for {@code and}, {@code or} and {@code not}.
7    */
8   public abstract class AbstractSpecification<T> implements Specification<T> {
9   
10    /**
11     * {@inheritDoc}
12     */
13    public abstract boolean isSatisfiedBy(T t);
14  
15    /**
16     * {@inheritDoc}
17     */
18    public Specification<T> and(final Specification<T> specification) {
19      return new AndSpecification<T>(this, specification);
20    }
21  
22    /**
23     * {@inheritDoc}
24     */
25    public Specification<T> or(final Specification<T> specification) {
26      return new OrSpecification<T>(this, specification);
27    }
28  
29    /**
30     * {@inheritDoc}
31     */
32    public Specification<T> not(final Specification<T> specification) {
33      return new NotSpecification<T>(specification);
34    }
35  }