public final class Main {
public static void main
(String[] args
) { var yellow
= Color.
findByName("YELLOW"); var rgb = yellow.getRgb();
// Needs to check whether or not 'rgb' is -1 after all.
}
/** Represents the invalid color. */
static final Color INVALID
= () -> -1;
/**
Returns the Color instance that matches with the specified name.
@param name
...
@return
{@code null} if nothing matches with {@code name}.
Otherwise, the instance that matches.
*/
return INVALID;
}
/**
Returns the 24-bit integer value representing RGB.
@return
-1 if this object is invalid.
Otherwise, the 24-bit integer value representing RGB.
*/
int getRgb();
}
}
cHVibGljIGZpbmFsIGNsYXNzIE1haW4gewoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgdmFyIHllbGxvdyA9IENvbG9yLmZpbmRCeU5hbWUoIllFTExPVyIpOwogICAgICAgIHZhciByZ2IgPSB5ZWxsb3cuZ2V0UmdiKCk7CgkJLy8gTmVlZHMgdG8gY2hlY2sgd2hldGhlciBvciBub3QgJ3JnYicgaXMgLTEgYWZ0ZXIgYWxsLgogICAgfQoKICAgIHB1YmxpYyBpbnRlcmZhY2UgQ29sb3IgewoKCSAgICAvKiogUmVwcmVzZW50cyB0aGUgaW52YWxpZCBjb2xvci4gKi8KICAgICAgICBzdGF0aWMgZmluYWwgQ29sb3IgSU5WQUxJRCA9ICgpIC0+IC0xOwoKICAgICAgICAvKioKCSAgICAgICAgUmV0dXJucyB0aGUgQ29sb3IgaW5zdGFuY2UgdGhhdCBtYXRjaGVzIHdpdGggdGhlIHNwZWNpZmllZCBuYW1lLgoKICAgICAgICAgICAgQHBhcmFtIG5hbWUKICAgICAgICAgICAgICAgIC4uLgogICAgICAgICAgICBAcmV0dXJuCgkgICAgICAgICAgICB7QGNvZGUgbnVsbH0gaWYgbm90aGluZyBtYXRjaGVzIHdpdGgge0Bjb2RlIG5hbWV9LgoJICAgICAgICAgICAgT3RoZXJ3aXNlLCB0aGUgaW5zdGFuY2UgdGhhdCBtYXRjaGVzLgogICAgICAgICovCiAgICAgICAgc3RhdGljIENvbG9yIGZpbmRCeU5hbWUoU3RyaW5nIG5hbWUpIHsKICAgICAgICAgICAgcmV0dXJuIElOVkFMSUQ7CiAgICAgICAgfQoKICAgICAgICAvKioKCSAgICAgICAgUmV0dXJucyB0aGUgMjQtYml0IGludGVnZXIgdmFsdWUgcmVwcmVzZW50aW5nIFJHQi4KCiAgICAgICAgICAgIEByZXR1cm4KICAgICAgICAgICAgCS0xIGlmIHRoaXMgb2JqZWN0IGlzIGludmFsaWQuCiAgICAgICAgICAgIAlPdGhlcndpc2UsIHRoZSAyNC1iaXQgaW50ZWdlciB2YWx1ZSByZXByZXNlbnRpbmcgUkdCLgogICAgICAgICovCiAgICAgICAgaW50IGdldFJnYigpOwogICAgfQp9Cg==