1 /*
2  * Copyright (c) 2007 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 package org.mockito.internal.stubbing.answers;
6 
7 import java.io.Serializable;
8 
9 import org.mockito.invocation.InvocationOnMock;
10 import org.mockito.stubbing.Answer;
11 
12 public class Returns implements Answer<Object>, Serializable {
13 
14     private static final long serialVersionUID = -6245608253574215396L;
15     private final Object value;
16 
Returns(Object value)17     public Returns(Object value) {
18         this.value = value;
19     }
20 
answer(InvocationOnMock invocation)21     public Object answer(InvocationOnMock invocation) throws Throwable {
22         return value;
23     }
24 
printReturnType()25     public String printReturnType() {
26         return value.getClass().getSimpleName();
27     }
28 
getReturnType()29     public Class<?> getReturnType() {
30         return value.getClass();
31     }
32 
returnsNull()33     public boolean returnsNull() {
34         return value == null;
35     }
36 
37     @Override
toString()38     public String toString() {
39         return "Returns: " + value;
40     }
41 }