boolean (@Nullable String text) { if (!StringUtil.startsWithChar(text, '#')) return false; //noinspection ConstantConditions - StringUtil#startsWithChar checks for null if (text.length() != HEX_COLOR_LENGTH_RGB && text.length() != HEX_COLOR_LENGTH_RGBA) return false; return COLOR_HEX_PATTERN_RGB.matcher(text).matches() || COLOR_HEX_PATTERN_RGBA.matcher(text).matches(); }