BorderTop extends AbstractCssProperty<BorderTop> implements StateChangeInformer<CssProperty> { public static boolean isValid(final String cssValue) { if (cssValue == null || StringUtil.isBlank(cssValue)) { return false; } final List<String> cssValueParts = CssValueUtil.split(cssValue); BorderTopWidth borderTopWidth = null; BorderTopStyle borderTopStyle = null; BorderTopColor borderTopColor = null; for (final String eachPart : cssValueParts) { boolean invalid = true; if (borderTopWidth == null && BorderTopWidth.isValid(eachPart)) { borderTopWidth = new BorderTopWidth(eachPart); invalid = false; } else if (borderTopStyle == null && BorderTopStyle.isValid(eachPart)) { borderTopStyle = BorderTopStyle.getThis(eachPart); invalid = false; } else if (borderTopColor == null && BorderTopColor.isValid(eachPart)) { borderTopColor = new BorderTopColor(eachPart); invalid = false; } if (invalid) { return false; } } return borderTopWidth != null || borderTopStyle != null || borderTopColor != null; } BorderTop();  BorderTop(final String cssValue);  BorderTop(final BorderTop borderTop); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); @Override BorderTop setCssValue(final String cssValue); static boolean isValid(final String cssValue); void setAsInitial(); void setAsInherit(); BorderTopColor getBorderTopColor(); BorderTopStyle getBorderTopStyle(); BorderTopWidth getBorderTopWidth(); BorderTop setBorderTopWidth(final BorderTopWidth borderTopWidth); BorderTop setBorderTopStyle(final BorderTopStyle borderTopStyle); BorderTop setBorderTopColor(final BorderTopColor borderTopColor); @Override void stateChanged(final CssProperty stateChangedObject); static final String INITIAL; static final String INHERIT; }
@Test public void testIsValid() { assertTrue(BorderTop.isValid("55px solid green")); assertTrue(BorderTop.isValid("55px solid rgb(25, 255, 155)")); assertTrue(BorderTop.isValid("55px")); assertTrue(BorderTop.isValid("solid")); assertTrue(BorderTop.isValid("green")); assertTrue(BorderTop.isValid(BorderTopWidth.MEDIUM + " " + BorderTopStyle.DASHED.getCssValue() + " " + CssColorName.AZURE)); assertTrue(BorderTop.isValid(BorderTopWidth.THICK + " " + BorderTopStyle.DOUBLE.getCssValue() + " " + CssColorName.AZURE)); assertFalse(BorderTop.isValid("cir cle inside url(Test.png)")); assertFalse(BorderTop.isValid("dmedium dfdf dfdfd")); assertFalse(BorderTop.isValid("medium medium medium ")); assertFalse(BorderTop.isValid("55 solid green")); assertFalse(BorderTop.isValid("solid solid solid")); assertFalse(BorderTop.isValid("55px solid green green")); }