### Question:
ColorFunctions { @ScalarFunction @LiteralParameters("x") @SqlType(ColorType.NAME) public static long color(@SqlType("varchar(x)") Slice color) { int rgb = parseRgb(color); if (rgb != -1) { return rgb; } 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); } } private  ColorFunctions(); @ScalarFunction @LiteralParameters("x") @SqlType(ColorType.NAME) static long color(@SqlType("varchar(x)") Slice color); @ScalarFunction @SqlType(ColorType.NAME) static long rgb(@SqlType(StandardTypes.BIGINT) long red, @SqlType(StandardTypes.BIGINT) long green, @SqlType(StandardTypes.BIGINT) long blue); @ScalarFunction @SqlType(ColorType.NAME) static long color(
            @SqlType(StandardTypes.DOUBLE) double value,
            @SqlType(StandardTypes.DOUBLE) double low,
            @SqlType(StandardTypes.DOUBLE) double high,
            @SqlType(ColorType.NAME) long lowColor,
            @SqlType(ColorType.NAME) long highColor); @ScalarFunction @SqlType(ColorType.NAME) static long color(@SqlType(StandardTypes.DOUBLE) double fraction, @SqlType(ColorType.NAME) long lowColor, @SqlType(ColorType.NAME) long highColor); @ScalarFunction @LiteralParameters({"x", "y"}) @Constraint(variable = "y", expression = "min(2147483647, x + 15)") // Color formatting uses 15 characters. Note that if the ansiColorEscape function implementation // changes, this value may be invalidated. @SqlType("varchar(y)") static Slice render(@SqlType("varchar(x)") Slice value, @SqlType(ColorType.NAME) long color); @ScalarFunction @SqlType("varchar(35)") static Slice render(@SqlType(StandardTypes.BIGINT) long value, @SqlType(ColorType.NAME) long color); @ScalarFunction @SqlType("varchar(41)") static Slice render(@SqlType(StandardTypes.DOUBLE) double value, @SqlType(ColorType.NAME) long color); @ScalarFunction @SqlType("varchar(16)") static Slice render(@SqlType(StandardTypes.BOOLEAN) boolean value); @ScalarFunction @SqlType(StandardTypes.VARCHAR) static Slice bar(@SqlType(StandardTypes.DOUBLE) double percent, @SqlType(StandardTypes.BIGINT) long width); @ScalarFunction @SqlType(StandardTypes.VARCHAR) static Slice bar(
            @SqlType(StandardTypes.DOUBLE) double percent,
            @SqlType(StandardTypes.BIGINT) long width,
            @SqlType(ColorType.NAME) long lowColor,
            @SqlType(ColorType.NAME) long highColor);  }### Answer:
@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); }