class CategorizedColor extends CategorizedLegend<Color> {

    @Override
    public Color remove(Double d){
        if(d==null){
            throw new NullPointerException("The input threshold must not be null");
        }
        if(parameter instanceof ColorLiteral){
            return null;
        } else {
            Categorize2Color c2s = (Categorize2Color) parameter;
            ColorParameter ret = c2s.remove(new RealLiteral(d));
            if(ret == null){
                return null;
            } else if(c2s.getNumClasses()==1 && c2s.getFallbackValue().equals(c2s.get(0))){
                parameter = new ColorLiteral(c2s.getFallbackValue().getColor(null));
            }
            if(ret instanceof ColorLiteral){
                try{
                    return ret.getColor(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 ColorLiteral in this categorize.");
            }
        }
    }

}

class CategorizedColorTest {

    @Test
    public void testRemoveFromLiteral(){

        CategorizedColor cs = new CategorizedColor(new ColorLiteral("#EDCBA0"));
        assertNull(cs.remove(50.0));
        assertNull(cs.remove(Double.NEGATIVE_INFINITY));
    }

}