WriteUtil { public String toString(final int value) { if (-this.maxInt <= value && value < this.maxInt) { final int i = value + this.maxInt; if (this.ints[i] == null) { this.ints[i] = Integer.toString(value); } return this.ints[i]; } else { return Integer.toString(value); } } WriteUtil(final int maxInt); static WriteUtil create(); String toString(final int value);  }
@Test public final void test() { Assert.assertEquals("1", this.util.toString(1)); Assert.assertEquals("1", this.util.toString(1)); Assert.assertEquals("1001", this.util.toString(1001)); Assert.assertEquals("1001", this.util.toString(1001)); Assert.assertEquals("-500", this.util.toString(-500)); Assert.assertEquals("-500", this.util.toString(-500)); Assert.assertEquals("-1001", this.util.toString(-1001)); Assert.assertEquals("-1001", this.util.toString(-1001)); }