Region { public Number center() { return getMax().doubleValue() - (length().doubleValue() / 2); } Region();  Region(Number v1, Number v2); static Region withDefaults(Region defaults); void setMinMax(Region region); static Number measure(Number v1, Number v2); Number length(); boolean contains(Number value); boolean intersects(Region region); Number center(); Number transform(double value, Region region2); Number transform(double value, Region region2, boolean flip); double transform(double value, double min, double max, boolean flip); Number ratio(Region r2); double ratio(double min, double max); void union(Number value); void union(Region input); void intersect(Region input); boolean intersects(Number line2Min, Number line2Max); boolean isMinSet(); Number getMin(); void setMin(Number min); boolean isMaxSet(); Number getMax(); void setMax(Number max); boolean isDefined(); @Override String toString();  }
@Test public void testCenter() throws Exception { Region r1 = new Region(1, 2); assertEquals(1.5, r1.center()); Region r2 = new Region(-10, 10); assertEquals(0.0, r2.center()); Region r3 = new Region(-2, -1); assertEquals(-1.5, r3.center()); }