Margin extends AbstractCssProperty<Margin> implements StateChangeInformer<CssProperty> { public static boolean isValid(final String cssValue) { final String trimmedCssValue; if (cssValue == null || (trimmedCssValue = TagStringUtil .toLowerCase(StringUtil.strip(cssValue))).isEmpty()) { return false; } if (PREDEFINED_CONSTANTS.contains(trimmedCssValue)) { return true; } final String[] cssValueParts = StringUtil.splitBySpace(trimmedCssValue); for (final String eachPart : cssValueParts) { final boolean valid = MarginTop.isValid(eachPart); if ((valid && (INITIAL.equals(eachPart) || INHERIT.equals(eachPart))) || !valid) { return false; } } return true; } Margin();  Margin(final String cssValue);  Margin(final Margin marginBottom); Margin setValue(final String value); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); String getValue(); @Override Margin setCssValue(final String cssValue); void setAsInitial(); void setAsInherit(); void setAsAuto(); MarginTop getMarginTop(); void setMargin(final MarginTop marginTop,
            final MarginRight marginRight, final MarginBottom marginBottom,
            final MarginLeft marginLeft); MarginRight getMarginRight(); MarginBottom getMarginBottom(); MarginLeft getMarginLeft(); @Override void stateChanged(final CssProperty stateChangedObject); boolean hasPredefinedConstantValue(); static boolean isValid(final String cssValue); static final String INITIAL; static final String INHERIT; }
@Test public void testIsValid() { { final boolean valid = Margin.isValid("45px"); assertTrue(valid); final boolean invalid = Margin.isValid("55"); assertFalse(invalid); } { final boolean valid = Margin.isValid("45PX"); assertTrue(valid); } { final boolean valid = Margin.isValid("45em"); assertTrue(valid); final boolean invalid = Margin.isValid("dfd"); assertFalse(invalid); } { final boolean valid = Margin.isValid("45%"); assertTrue(valid); final boolean invalid = Margin.isValid("45 px"); assertFalse(invalid); } { final boolean valid = Margin.isValid("45em"); assertTrue(valid); final boolean invalid = Margin.isValid("45sem"); assertFalse(invalid); } { final boolean valid = Margin.isValid("45rem"); assertTrue(valid); } { final boolean valid = Margin.isValid("--1px"); assertFalse(valid); } { final boolean valid = Margin.isValid("25px 23px 17px -1px"); assertTrue(valid); } { final boolean valid = Margin.isValid("-25px 23px 17px 1px"); assertTrue(valid); } { final boolean valid = Margin.isValid("25px -23px 17px 1px"); assertTrue(valid); } { final boolean valid = Margin.isValid("25px 23px -17px 1px"); assertTrue(valid); } { final boolean valid = Margin.isValid("25px 23px 17px -1px"); assertTrue(valid); } { final boolean valid = Margin.isValid("25px 23px 17px initial"); assertFalse(valid); } { final boolean valid = Margin.isValid("25px 23px 17PX initial"); assertFalse(valid); } { final boolean valid = Margin.isValid("25px 23px 17PX initial"); assertFalse(valid); } { final boolean valid = Margin.isValid("25px 23px 17px INHERIT"); assertFalse(valid); } }