@Test public void testCaching() throws ParseException { for (FormatChar c : FormatChar.values()) { for (int n = 0; n < 10; n++) { assertThat(SimpleParameter.of(n, c, FormatOptions.getDefault())) .isSameInstanceAs(SimpleParameter.of(n, c, FormatOptions.getDefault())); } } assertThat(SimpleParameter.of(1, FormatChar.DECIMAL, FormatOptions.getDefault())) .isNotSameInstanceAs(SimpleParameter.of(0, FormatChar.DECIMAL, FormatOptions.getDefault())); assertThat(SimpleParameter.of(0, FormatChar.FLOAT, FormatOptions.getDefault())) .isNotSameInstanceAs(SimpleParameter.of(0, FormatChar.DECIMAL, FormatOptions.getDefault())); assertThat(SimpleParameter.of(0, FormatChar.DECIMAL, FormatOptions.parse("-10", 0, 3, false))) .isNotSameInstanceAs(SimpleParameter.of(0, FormatChar.DECIMAL, FormatOptions.getDefault())); }
public static SimpleParameter of(int index, FormatChar formatChar, FormatOptions options) { if (index < MAX_CACHED_PARAMETERS && options.isDefault()) { return DEFAULT_PARAMETERS.get(formatChar)[index]; } return new SimpleParameter(index, formatChar, options); }
SimpleParameter extends Parameter { public static SimpleParameter of(int index, FormatChar formatChar, FormatOptions options) { if (index < MAX_CACHED_PARAMETERS && options.isDefault()) { return DEFAULT_PARAMETERS.get(formatChar)[index]; } return new SimpleParameter(index, formatChar, options); } }
SimpleParameter extends Parameter { public static SimpleParameter of(int index, FormatChar formatChar, FormatOptions options) { if (index < MAX_CACHED_PARAMETERS && options.isDefault()) { return DEFAULT_PARAMETERS.get(formatChar)[index]; } return new SimpleParameter(index, formatChar, options); } private  SimpleParameter(int index, FormatChar formatChar, FormatOptions options); }
SimpleParameter extends Parameter { public static SimpleParameter of(int index, FormatChar formatChar, FormatOptions options) { if (index < MAX_CACHED_PARAMETERS && options.isDefault()) { return DEFAULT_PARAMETERS.get(formatChar)[index]; } return new SimpleParameter(index, formatChar, options); } private  SimpleParameter(int index, FormatChar formatChar, FormatOptions options); static SimpleParameter of(int index, FormatChar formatChar, FormatOptions options); @Override String getFormat(); }
SimpleParameter extends Parameter { public static SimpleParameter of(int index, FormatChar formatChar, FormatOptions options) { if (index < MAX_CACHED_PARAMETERS && options.isDefault()) { return DEFAULT_PARAMETERS.get(formatChar)[index]; } return new SimpleParameter(index, formatChar, options); } private  SimpleParameter(int index, FormatChar formatChar, FormatOptions options); static SimpleParameter of(int index, FormatChar formatChar, FormatOptions options); @Override String getFormat();  }