@ScalarFunction
    @LiteralParameters("x")
    @SqlType(ColorType.NAME)
    public static long color(@SqlType("varchar(x)") Slice color)
    {
        int rgb = parseRgb(color);

        if (rgb != -1) {
            return rgb;
        }

        // encode system colors (0-15) as negative values, offset by one
        try {
            SystemColor systemColor = SystemColor.valueOf(upper(color).toStringUtf8());
            int index = systemColor.getIndex();
            return -(index + 1);
        }
        catch (IllegalArgumentException e) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Invalid color: '%s'", color.toStringUtf8()), e);
        }
    }
@Test
    public void testColor()
    {
        assertEquals(color(toSlice("black")), -1);
        assertEquals(color(toSlice("red")), -2);
        assertEquals(color(toSlice("green")), -3);
        assertEquals(color(toSlice("yellow")), -4);
        assertEquals(color(toSlice("blue")), -5);
        assertEquals(color(toSlice("magenta")), -6);
        assertEquals(color(toSlice("cyan")), -7);
        assertEquals(color(toSlice("white")), -8);

        assertEquals(color(toSlice("#f00")), 0xFF_00_00);
        assertEquals(color(toSlice("#0f0")), 0x00_FF_00);
        assertEquals(color(toSlice("#00f")), 0x00_00_FF);
    }