1 5 package com.mockobjects.dynamic; 6 7 import com.mockobjects.constraint.*; 8 9 10 12 public abstract class C 13 { 14 public static final IsAnything IS_ANYTHING = new IsAnything(); 15 public static final IsNull IS_NULL = new IsNull(); 16 public static final Constraint IS_NOT_NULL = not(IS_NULL); 17 public static final Constraint IS_TRUE = eq(new Boolean (true)); 18 public static final Constraint IS_FALSE = eq(new Boolean (false)); 19 public static final Constraint IS_ZERO = eq(new Integer (0)); 20 public static final Constraint IS_NOT_ZERO = not(IS_ZERO); 21 22 public static final ConstraintMatcher NO_ARGS = new FullConstraintMatcher(new Constraint[0]); 23 public static final ConstraintMatcher ANY_ARGS = new AnyConstraintMatcher(); 24 25 public static Constraint same( Object o ) { 26 return new IsSame(o); 27 } 28 29 public static Constraint eq( Object o ) { 30 return new IsEqual(o); 31 } 32 33 public static ConstraintMatcher eq( Object arg0, Object arg1 ) { 34 return args(eq(arg0), eq(arg1)); 35 } 36 37 public static ConstraintMatcher eq( Object arg0, Object arg1, Object arg2 ) { 38 return args(eq(arg0), eq(arg1), eq(arg2)); 39 } 40 41 public static Constraint eq( int n ) { 42 return new IsEqual( new Integer (n) ); 43 } 44 45 public static Constraint eq( long l ) { 46 return new IsEqual( new Long (l) ); 47 } 48 49 public static Constraint eq( double d ) { 50 return new IsEqual( new Double (d) ); 51 } 52 53 public static Constraint gt( int n ) { 54 return new IsGreaterThan( new Integer (n) ); 55 } 56 57 public static Constraint gt( long l ) { 58 return new IsGreaterThan( new Long (l) ); 59 } 60 61 public static Constraint gt( double d ) { 62 return new IsGreaterThan( new Double (d) ); 63 } 64 65 public static Constraint gt( char c ) { 66 return new IsGreaterThan( new Character (c) ); 67 } 68 69 public static Constraint lt( int n ) { 70 return new IsLessThan( new Integer (n) ); 71 } 72 73 public static Constraint lt( long l ) { 74 return new IsLessThan( new Long (l) ); 75 } 76 77 public static Constraint lt( double d ) { 78 return new IsLessThan( new Double (d) ); 79 } 80 81 public static Constraint lt( char c ) { 82 return new IsLessThan( new Character (c) ); 83 } 84 85 public static Constraint not( Constraint p ) { 86 return new IsNot(p); 87 } 88 89 public static Constraint and( Constraint p1, Constraint p2 ) { 90 return new And(p1,p2); 91 } 92 93 public static Constraint or( Constraint p1, Constraint p2 ) { 94 return new Or(p1,p2); 95 } 96 97 public static Constraint isA( Class c ) { 98 return new IsInstanceOf(c); 99 } 100 101 102 103 105 106 public static ConstraintMatcher args() { 107 return NO_ARGS; 108 } 109 110 public static ConstraintMatcher args(Constraint p) { 111 return new FullConstraintMatcher(new Constraint[]{p}); 112 } 113 114 public static ConstraintMatcher args(Constraint p1, Constraint p2) { 115 return new FullConstraintMatcher(new Constraint[]{p1, p2}); 116 } 117 118 public static ConstraintMatcher args(Constraint p1, Constraint p2, Constraint p3) { 119 return new FullConstraintMatcher(new Constraint[]{p1, p2, p3}); 120 } 121 122 public static ConstraintMatcher anyArgs( int argCount) { 123 Constraint[] constraints = new Constraint[argCount]; 124 for (int i = 0; i < constraints.length; i++) { 125 constraints[i] = new IsAnything(); 126 } 127 128 return new FullConstraintMatcher(constraints); 129 } 130 } 131 | Popular Tags |