HslaCssValue extends AbstractBean<HslaCssValue> { public static boolean isValid(final String hslString) { try { final String hslStringLowerCase = hslString.replace(" ", "") .toLowerCase(); if (hslStringLowerCase.startsWith("hsla(") && hslStringLowerCase.contains(")")) { final String[] hslStringParts = StringUtil .splitByComma(hslStringLowerCase.substring( hslStringLowerCase.indexOf('(') + 1, hslStringLowerCase.lastIndexOf(')'))); if (hslStringParts.length == 4) { final int r = Integer.parseInt(hslStringParts[0]); if (r < 0 || r > 360) { return false; } if (!hslStringParts[1].endsWith("%")) { return false; } final float g = Float .parseFloat(hslStringParts[1].replace("%", "")); if (g < 0 || g > 100) { return false; } if (!hslStringParts[2].endsWith("%")) { return false; } final float b = Float .parseFloat(hslStringParts[2].replace("%", "")); if (b < 0 || b > 100) { return false; } final float a = Float.parseFloat(hslStringParts[3]); return !(a < 0 || a > 1); } return false; } } catch (final NumberFormatException e) { } return false; } HslaCssValue();  HslaCssValue(final String hslCssValue);  HslaCssValue(final HslaCssValue hslCssValue);  HslaCssValue(final int h, final float s, final float l,
            final float a); void setHsla(final String hsl); int getH(); void setH(final int h); float getS(); void setS(final float s); float getL(); static CssLengthUnit getSUnit(); static CssLengthUnit getLUnit(); void setL(final float l); void setA(final float a); float getA(); @Override String toString(); @Override String getValue(); static boolean isValid(final String hslString);  }
@Test public void testIsValid() { assertTrue(HslaCssValue.isValid("hsla(0, 0%, 0%, 1)")); assertTrue(HslaCssValue.isValid("hsla(0, 0.0%, 0.0%, 1)")); assertTrue(HslaCssValue.isValid("hsla(0, 0.0%, 0%, 1)")); assertTrue(HslaCssValue.isValid("hsla(0, 0%, 0.0%, 1)")); assertTrue(HslaCssValue.isValid("hsla(0, 0%, 100%, 1)")); assertTrue(HslaCssValue.isValid("hsla(0, 10%, 100%, 1)")); assertTrue(HslaCssValue.isValid("hsla(120, 100%, 10%, 1)")); assertFalse(HslaCssValue.isValid("hsla(0, 10, 100%)")); assertFalse(HslaCssValue.isValid("hsla(0, 10%, 100)")); assertFalse(HslaCssValue.isValid("hsla(0, 10%, 101%)")); assertFalse(HslaCssValue.isValid("hsla(0, 101%, 100%)")); assertFalse(HslaCssValue.isValid("hsla(-1, 100%, 100%)")); assertFalse(HslaCssValue.isValid("hsla(361, 100%, 100%)")); assertFalse(HslaCssValue.isValid("hsla(36df1, 100%, 100%)")); assertFalse(HslaCssValue.isValid("hsla(120, 10df0%, 10%)")); assertFalse(HslaCssValue.isValid("hsla(120, 100%, 1dfd0%)")); }