1 3 package org.jmock.expectation; 4 5 6 32 public class ReturnValue 33 { 34 private final String name; 35 private Object value; 36 37 40 public ReturnValue( String name ) { 41 this.name = name; 42 } 43 44 49 public Object getValue() { 50 AssertMo.assertNotNull("The return value \"" + name + "\" has not been set.", value); 51 52 if (value instanceof Null) { 53 return null; 54 } 55 56 return value; 57 } 58 59 62 public void setValue( Object value ) { 63 if (value == null) { 64 this.value = Null.NULL; 65 } else { 66 this.value = value; 67 } 68 } 69 70 74 public void setValue( boolean value ) { 75 setValue(new Boolean (value)); 76 } 77 78 81 public boolean getBooleanValue() { 82 return ((Boolean )getValue()).booleanValue(); 83 } 84 85 88 public int getIntValue() { 89 return ((Number )getValue()).intValue(); 90 } 91 92 96 public void setValue( int value ) { 97 setValue(new Integer (value)); 98 } 99 100 104 public void setValue( long value ) { 105 setValue(new Long (value)); 106 } 107 108 111 public long getLongValue() { 112 return ((Number )getValue()).longValue(); 113 } 114 115 116 } | Popular Tags |