BorderWidth extends AbstractCssProperty<BorderWidth> implements StateChangeInformer<CssProperty> { public static boolean isValid(final String cssValue) { final String trimmedCssValue = StringUtil.strip(cssValue).toLowerCase(); final String[] cssValueParts = StringUtil.splitBySpace(trimmedCssValue); if (cssValueParts.length > 4) { return false; } for (final String cssValuePart : cssValueParts) { boolean invalidValue = true; for (final CssLengthUnit cssLengthUnit : CssLengthUnit.values()) { final String unit = cssLengthUnit.getUnit(); if (cssValuePart.endsWith(unit)) { final String valueOnly = cssValuePart.replaceFirst(unit, ""); try { Float.parseFloat(valueOnly); } catch (final NumberFormatException e) { break; } invalidValue = false; break; } } if (PREDEFINED_CONSTANTS.contains(cssValuePart)) { invalidValue = false; } if (invalidValue) { return false; } } return true; } BorderWidth();  BorderWidth(final String cssValue);  BorderWidth(final BorderWidth borderBottomWidth);  BorderWidth(final float percent);  BorderWidth(final float value, final CssLengthUnit cssLengthUnit); BorderWidth setValue(final float value,
            final CssLengthUnit cssLengthUnit); void setPercent(final float percent); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); @Override BorderWidth setCssValue(final String cssValue); void setAsInitial(); void setAsInherit(); void setAsMedium(); void setAsThin(); void setAsThick(); void setBorderWidth(final BorderTopWidth borderTopWidth,
            final BorderRightWidth borderRightWidth,
            final BorderBottomWidth borderBottomWidth,
            final BorderLeftWidth borderLeftWidth); BorderTopWidth getBorderTopWidth(); BorderRightWidth getBorderRightWidth(); BorderBottomWidth getBorderBottomWidth(); BorderLeftWidth getBorderLeftWidth(); @Override void stateChanged(final CssProperty stateChangedObject); static boolean isValid(final String cssValue); boolean hasPredefinedConstantValue(); static final String MEDIUM; static final String THIN; static final String THICK; static final String INITIAL; static final String INHERIT; }
@Test public void testIsValid() { { final boolean valid = BorderWidth.isValid("45px"); assertTrue(valid); final boolean invalid = BorderWidth.isValid("55"); assertFalse(invalid); } { final boolean valid = BorderWidth.isValid("45em 45px"); assertTrue(valid); final boolean invalid = BorderWidth.isValid("45em dfd 45px"); assertFalse(invalid); } { final boolean valid = BorderWidth.isValid("45%"); assertTrue(valid); final boolean invalid = BorderWidth.isValid("45 px"); assertFalse(invalid); } { final boolean valid = BorderWidth.isValid("45em"); assertTrue(valid); final boolean invalid = BorderWidth.isValid("45sem"); assertFalse(invalid); } { final boolean valid = BorderWidth.isValid("45rem"); assertTrue(valid); } }