1 /*
2  * Copyright (c) 2016 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 package org.mockito.stubbing;
6 
7 import org.mockito.Incubating;
8 
9 /**
10  * Generic interface to be used for configuring mock's answer for a four argument invocation.
11  *
12  * Answer specifies an action that is executed and a return value that is returned when you interact with the mock.
13  * <p>
14  * Example of stubbing a mock with this custom answer:
15  *
16  * <pre class="code"><code class="java">
17  * import static org.mockito.AdditionalAnswers.answer;
18  *
19  * when(mock.someMethod(anyInt(), anyString(), anyChar(), any())).then(answer(
20  *     new Answer4&lt;StringBuilder, Integer, String, Character, Object&gt;() {
21  *         public StringBuilder answer(Integer i, String s, Character c, Object o) {
22  *             return new StringBuilder().append(i).append(s).append(c).append(o.hashCode());
23  *         }
24  * }));
25  *
26  * //Following will print a string like "3xyz131635550"
27  * System.out.println(mock.someMethod(3, "xy", 'z', new Object()));
28  * </code></pre>
29  *
30  * @param <T> return type
31  * @param <A0> type of the first argument
32  * @param <A1> type of the second argument
33  * @param <A2> type of the third argument
34  * @param <A3> type of the fourth argument
35  * @see Answer
36  */
37 @Incubating
38 public interface Answer4<T, A0, A1, A2, A3> {
39     /**
40      * @param argument0 the first argument.
41      * @param argument1 the second argument.
42      * @param argument2 the third argument.
43      * @param argument3 the fourth argument.
44      *
45      * @return the value to be returned.
46      *
47      * @throws Throwable the throwable to be thrown
48      */
answer(A0 argument0, A1 argument1, A2 argument2, A3 argument3)49     T answer(A0 argument0, A1 argument1, A2 argument2, A3 argument3) throws Throwable;
50 }
51