OBackgroundSize extends AbstractCssProperty<OBackgroundSize> { public static boolean isValid(final String cssValue) { final String trimmedCssValue = TagStringUtil .toLowerCase(StringUtil.strip(cssValue)); final String[] cssValueParts = StringUtil.splitBySpace(trimmedCssValue); if (cssValueParts.length > 2) { return false; } if (PREDEFINED_CONSTANTS.contains(trimmedCssValue)) { return true; } boolean valid = false; for (final String each : cssValueParts) { final Object[] lengthValueAndUnit = CssLengthUtil .getLengthValueAsPremitiveAndUnit(each); if (lengthValueAndUnit.length != 2) { return false; } valid = true; } return valid; } OBackgroundSize();  OBackgroundSize(final String cssValue);  OBackgroundSize(final OBackgroundSize backgroundSize);  OBackgroundSize(final float horizontalHeight,
            final CssLengthUnit cssLengthUnit);  OBackgroundSize(final float width,
            final CssLengthUnit widthCssLengthUnit, final float height,
            final CssLengthUnit heightCssLengthUnit); OBackgroundSize setValue(final float width,
            final CssLengthUnit widthCssLengthUnit, final float height,
            final CssLengthUnit heightCssLengthUnit); OBackgroundSize setValue(final float widthHeight,
            final CssLengthUnit cssLengthUnit); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); Float getWidth(); Float getHeight(); CssLengthUnit getWidthUnit(); CssLengthUnit getHeightUnit(); @Override OBackgroundSize setCssValue(final String cssValue); void setAsInitial(); void setAsInherit(); static boolean isValid(final String cssValue); static final String INITIAL; static final String INHERIT; static final String AUTO; static final String COVER; static final String CONTAIN; }
@Test public void testIsValid() { assertTrue(OBackgroundSize.isValid("55px")); assertTrue(OBackgroundSize.isValid("55px 85cm")); assertTrue(OBackgroundSize.isValid("55% 85cm")); assertTrue(OBackgroundSize.isValid("12% 12%")); assertFalse(OBackgroundSize.isValid("12")); assertFalse(OBackgroundSize.isValid("12 25")); assertFalse(OBackgroundSize.isValid("sdfdf")); }