CategorizedString extends CategorizedLegend<String> { @Override public String remove(Double d){ if(d==null){ throw new NullPointerException("The input threshold must not be null"); } if(parameter instanceof StringLiteral){ return null; } else { Categorize2String c2s = (Categorize2String) parameter; StringParameter ret = c2s.remove(new RealLiteral(d)); if(ret == null){ return null; } else if(c2s.getNumClasses()==1 && c2s.getFallbackValue().equals(c2s.get(0))){ parameter = new StringLiteral(c2s.getFallbackValue().getValue(null)); } if(ret instanceof StringLiteral){ try{ return ret.getValue(null); } catch (ParameterException pe){ throw new IllegalStateException("We've failed at retrieved the value of a literal. " + "Something is going really wrong here."); } } else { throw new IllegalStateException("We're not supposed to have values that are not StringLiteral in this categorize."); } } } CategorizedString(StringParameter sp); @Override SeParameter getParameter(); void setParameter(StringParameter param); String getFallbackValue(); void setFallbackValue(String value); @Override String get(Double d); @Override void put(Double d, String v); @Override String remove(Double d); @Override String getFromLower(Double d);  }
@Test public void testRemoveFromLiteral(){ CategorizedString cs = new CategorizedString(new StringLiteral("yo")); assertNull(cs.remove(50.0)); assertNull(cs.remove(Double.NEGATIVE_INFINITY)); }
@Test public void testRemoveFromCat(){ CategorizedString cs = new CategorizedString(getCategorize2String()); assertTrue(cs.remove(20.0).equals("Greater")); assertNull(cs.remove(20.0)); }