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 three 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  * when(mock.someMethod(anyInt(), anyString(), anyChar())).thenAnswer(
18  *     new Answer&lt;StringBuilder, Integer, String, Character&gt;() {
19  *         StringBuilder answer(Integer i, String s, Character c) {
20  *             return new StringBuilder().append(i).append(s).append(c);
21  *         }
22  *     });
23  *
24  * //Following will print "3xyz"
25  * System.out.println(mock.someMethod(3, "xy", 'z'));
26  * </code></pre>
27  *
28  * @param <T> return type
29  * @param <A0> type of the first argument
30  * @param <A1> type of the second argument
31  * @param <A2> type of the third argument
32  * @see Answer
33  */
34 @Incubating
35 public interface Answer3<T, A0, A1, A2> {
36     /**
37      * @param argument0 the first argument.
38      * @param argument1 the second argument.
39      * @param argument2 the third argument.
40      *
41      * @return the value to be returned.
42      *
43      * @throws Throwable the throwable to be thrown
44      */
answer(A0 argument0, A1 argument1, A2 argument2)45     T answer(A0 argument0, A1 argument1, A2 argument2) throws Throwable;
46 }
47