@Test public void listToString() { List<Integer> years = Arrays.asList(); YearListCoiceRenderer renderer = new YearListCoiceRenderer(years); assertEquals(String.valueOf(YearListCoiceRenderer.CURRENT_YEAR), renderer.getDisplayValue(-1)); assertEquals("2005", renderer.getDisplayValue(2005)); years = Arrays.asList(-1); renderer = new YearListCoiceRenderer(years); assertEquals(String.valueOf(YearListCoiceRenderer.CURRENT_YEAR), renderer.getDisplayValue(-1)); assertEquals("2005", renderer.getDisplayValue(2005)); years = Arrays.asList(-1, 2007); renderer = new YearListCoiceRenderer(years); assertEquals("2007", renderer.getDisplayValue(-1)); assertEquals("2005", renderer.getDisplayValue(2005)); years = Arrays.asList(-1, 2007, 2008); renderer = new YearListCoiceRenderer(years); assertEquals("2007-2008", renderer.getDisplayValue(-1)); assertEquals("2005", renderer.getDisplayValue(2005)); }
@Override public Object getDisplayValue(Integer object) { if (object < 0) { if (minYear == maxYear) return String.valueOf(minYear); else return String.valueOf(minYear) + "-" + maxYear; } return object.toString(); }
YearListCoiceRenderer implements IChoiceRenderer<Integer> { @Override public Object getDisplayValue(Integer object) { if (object < 0) { if (minYear == maxYear) return String.valueOf(minYear); else return String.valueOf(minYear) + "-" + maxYear; } return object.toString(); } }
YearListCoiceRenderer implements IChoiceRenderer<Integer> { @Override public Object getDisplayValue(Integer object) { if (object < 0) { if (minYear == maxYear) return String.valueOf(minYear); else return String.valueOf(minYear) + "-" + maxYear; } return object.toString(); } YearListCoiceRenderer(List<Integer> years);  YearListCoiceRenderer(int[] years, boolean prependYearRange); }
YearListCoiceRenderer implements IChoiceRenderer<Integer> { @Override public Object getDisplayValue(Integer object) { if (object < 0) { if (minYear == maxYear) return String.valueOf(minYear); else return String.valueOf(minYear) + "-" + maxYear; } return object.toString(); } YearListCoiceRenderer(List<Integer> years);  YearListCoiceRenderer(int[] years, boolean prependYearRange); List<Integer> getYears(); @Override Object getDisplayValue(Integer object); @Override String getIdValue(Integer object, int index); @Override Integer getObject(final String s, final IModel<? extends List<? extends Integer>> iModel); }
YearListCoiceRenderer implements IChoiceRenderer<Integer> { @Override public Object getDisplayValue(Integer object) { if (object < 0) { if (minYear == maxYear) return String.valueOf(minYear); else return String.valueOf(minYear) + "-" + maxYear; } return object.toString(); } YearListCoiceRenderer(List<Integer> years);  YearListCoiceRenderer(int[] years, boolean prependYearRange); List<Integer> getYears(); @Override Object getDisplayValue(Integer object); @Override String getIdValue(Integer object, int index); @Override Integer getObject(final String s, final IModel<? extends List<? extends Integer>> iModel);  }