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