forked from jqno/equalsverifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EqualsVerifierApi.java
90 lines (82 loc) · 3.66 KB
/
EqualsVerifierApi.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package nl.jqno.equalsverifier.api;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Func.Func1;
import nl.jqno.equalsverifier.Func.Func2;
import nl.jqno.equalsverifier.Warning;
/**
* Helps to construct an {@link EqualsVerifier} test with a fluent API.
*
* @param <T> The class under test.
*/
public interface EqualsVerifierApi<T> {
/* package private */static final String WEBSITE_URL =
"For more information, go to: https://www.jqno.nl/equalsverifier/errormessages";
/**
* Suppresses warnings given by {@code EqualsVerifier}. See {@link Warning} to see what warnings
* can be suppressed.
*
* @param warnings A list of warnings to suppress in {@code EqualsVerifier}.
* @return {@code this}, for easy method chaining.
*/
public EqualsVerifierApi<T> suppress(Warning... warnings);
/**
* Adds prefabricated values for instance fields of classes that EqualsVerifier cannot
* instantiate by itself.
*
* @param <S> The class of the prefabricated values.
* @param otherType The class of the prefabricated values.
* @param red An instance of {@code S}.
* @param blue Another instance of {@code S}, not equal to {@code red}.
* @return {@code this}, for easy method chaining.
* @throws NullPointerException If either {@code otherType}, {@code red}, or {@code blue} is
* null.
* @throws IllegalArgumentException If {@code red} equals {@code blue}.
*/
public <S> EqualsVerifierApi<T> withPrefabValues(Class<S> otherType, S red, S blue);
/**
* Adds a factory to generate prefabricated values for instance fields of classes with 1 generic
* type parameter that EqualsVerifier cannot instantiate by itself.
*
* @param <S> The class of the prefabricated values.
* @param otherType The class of the prefabricated values.
* @param factory A factory to generate an instance of {@code S}, given a value of its generic
* type parameter.
* @return {@code this}, for easy method chaining.
* @throws NullPointerException if either {@code otherType} or {@code factory} is null.
*/
public <S> EqualsVerifierApi<T> withGenericPrefabValues(
Class<S> otherType,
Func1<?, S> factory
);
/**
* Adds a factory to generate prefabricated values for instance fields of classes with 2 generic
* type parameters that EqualsVerifier cannot instantiate by itself.
*
* @param <S> The class of the prefabricated values.
* @param otherType The class of the prefabricated values.
* @param factory A factory to generate an instance of {@code S}, given a value of each of its
* generic type parameters.
* @return {@code this}, for easy method chaining.
* @throws NullPointerException if either {@code otherType} or {@code factory} is null.
*/
public <S> EqualsVerifierApi<T> withGenericPrefabValues(
Class<S> otherType,
Func2<?, ?, S> factory
);
/**
* Signals that {@code getClass} is used in the implementation of the {@code equals} method,
* instead of an {@code instanceof} check.
*
* @return {@code this}, for easy method chaining.
* @see Warning#STRICT_INHERITANCE
*/
public EqualsVerifierApi<T> usingGetClass();
/**
* Signals that all internal caches need to be reset. This is useful when the test framework
* uses multiple ClassLoaders to run tests, causing {@link java.lang.Class} instances
* that would normally be equal, to be unequal, because their ClassLoaders don't match.
*
* @return {@code this}, for easy method chaining.
*/
public EqualsVerifierApi<T> withResetCaches();
}