IntegerDifference implements IDifference { public static IDifference construct(String name, Integer first, Integer second) { if (first == null && second == null) { return null; } if (first == null || second == null) { return new IntegerDifference(name, first, second); } if (first.intValue() == second.intValue()) { return null; } return new IntegerDifference(name, first, second); } private  IntegerDifference(String name, Integer first, Integer second); static IDifference construct(String name, Integer first, Integer second); @Override String toString();  }
@Test public void testDiff() { IDifference result = IntegerDifference.construct("Foo", 1, 2); Assert.assertNotNull(result); }
@Test public void testSame() { IDifference result = IntegerDifference.construct("Foo", 1, 1); Assert.assertNull(result); }
@Test public void testTwoNull() { IDifference result = IntegerDifference.construct("Foo", null, null); Assert.assertNull(result); }
@Test public void testOneNull() { IDifference result = IntegerDifference.construct("Foo", null, 1); Assert.assertNotNull(result); result = IntegerDifference.construct("Foo", 2, null); Assert.assertNotNull(result); }
@Test public void testRefs() { Integer x = new Integer(1); Integer y = new Integer(1); IDifference diff = IntegerDifference.construct("foo", x, y); Assert.assertNull(diff); }