DoubleDifference implements IDifference { public static IDifference construct(String name, Double first, Double second) { if (first == null && second == null) { return null; } if (first == null || second == null) { return new DoubleDifference(name, first, second); } if (Math.abs(first - second) < ERROR) { return null; } return new DoubleDifference(name, first, second); } private  DoubleDifference(String name, Double first, Double second); static IDifference construct(String name, Double first, Double second); @Override String toString();  }
@Test public void testDiff() { IDifference result = DoubleDifference.construct("Foo", 1.0, 3.0); Assert.assertNotNull(result); }
@Test public void testSame() { IDifference result = DoubleDifference.construct("Foo", 1.0, 1.0); Assert.assertNull(result); }
@Test public void testTwoNull() { IDifference result = DoubleDifference.construct("Foo", null, null); Assert.assertNull(result); }
@Test public void testOneNull() { IDifference result = DoubleDifference.construct("Foo", null, 1.0); Assert.assertNotNull(result); result = DoubleDifference.construct("Foo", 3.0, null); Assert.assertNotNull(result); }