View Javadoc

1   package se.citerus.dddsample.domain.shared;
2   
3   /**
4    * Specificaiton interface.
5    * <p/>
6    * Use {@link se.citerus.dddsample.domain.shared.AbstractSpecification} as base for creating specifications, and
7    * only the method {@link #isSatisfiedBy(Object)} must be implemented.
8    */
9   public interface Specification<T> {
10  
11    /**
12     * Check if {@code t} is satisfied by the specification.
13     *
14     * @param t Object to test.
15     * @return {@code true} if {@code t} satisfies the specification.
16     */
17    boolean isSatisfiedBy(T t);
18  
19    /**
20     * Create a new specification that is the AND operation of {@code this} specification and another specification.
21     * @param specification Specification to AND.
22     * @return A new specification.
23     */
24    Specification<T> and(Specification<T> specification);
25  
26    /**
27     * Create a new specification that is the OR operation of {@code this} specification and another specification.
28     * @param specification Specification to OR.
29     * @return A new specification.
30     */
31    Specification<T> or(Specification<T> specification);
32  
33    /**
34     * Create a new specification that is the NOT operation of {@code this} specification.
35     * @param specification Specification to NOT.
36     * @return A new specification.
37     */
38    Specification<T> not(Specification<T> specification);
39  }