1 package com.mockobjects; 2 3 import com.mockobjects.util.AssertMo; 4 import com.mockobjects.util.Null; 5 6 31 public class ReturnValue { 32 private final String name; 33 private Object value; 34 35 38 public ReturnValue(String name) { 39 this.name = name; 40 } 41 42 46 public Object getValue() { 47 AssertMo.assertNotNull("The return value \"" + name + "\" has not been set.", value); 48 49 if(value instanceof Null){ 50 return null; 51 } 52 53 return value; 54 } 55 56 59 public void setValue(Object value) { 60 if(value==null){ 61 this.value = Null.NULL; 62 }else{ 63 this.value = value; 64 } 65 } 66 67 71 public void setValue(boolean value){ 72 setValue(new Boolean (value)); 73 } 74 75 78 public boolean getBooleanValue() { 79 return ((Boolean )getValue()).booleanValue(); 80 } 81 82 85 public int getIntValue() { 86 return ((Number )getValue()).intValue(); 87 } 88 89 93 public void setValue(int value) { 94 setValue(new Integer (value)); 95 } 96 97 101 public void setValue(long value) { 102 setValue(new Long (value)); 103 } 104 105 108 public long getLongValue() { 109 return ((Number )getValue()).longValue(); 110 } 111 112 113 } | Popular Tags |