BorderWidth extends AbstractCssProperty<BorderWidth> implements StateChangeInformer<CssProperty> { @Override public BorderWidth setCssValue(final String cssValue) { if (cssValue == null) { throw new NullValueException( "null is an invalid value. The value format should be as for example 75px or 85%. Or, initial/inherit/medium/thin/thick."); } else if (StringUtil.isBlank(cssValue)) { throw new InvalidValueException( "blank string is an invalid value. The value format should be as for example 75px or 85%. Or, initial/inherit/medium/thin/thick."); } else { final String trimmedCssValue = StringUtil.strip(cssValue); if (PREDEFINED_CONSTANTS.contains(trimmedCssValue)) { this.cssValue = trimmedCssValue; if (borderTopWidth != null) { borderTopWidth.setAlreadyInUse(false); borderTopWidth = null; } if (borderRightWidth != null) { borderRightWidth.setAlreadyInUse(false); borderRightWidth = null; } if (borderBottomWidth != null) { borderBottomWidth.setAlreadyInUse(false); borderBottomWidth = null; } if (borderLeftWidth != null) { borderLeftWidth.setAlreadyInUse(false); borderLeftWidth = null; } if (getStateChangeInformer() != null) { getStateChangeInformer().stateChanged(this); } return this; } final String borderWidthString = StringUtil .convertToSingleSpace(trimmedCssValue); final String[] extractedWidths = StringUtil .splitBySpace(borderWidthString); if (extractedWidths.length == 1) { if (borderTopWidth == null) { borderTopWidth = new BorderTopWidth(extractedWidths[0]); borderTopWidth.setStateChangeInformer(this); borderTopWidth.setAlreadyInUse(true); } else { borderTopWidth.setCssValue(extractedWidths[0]); } if (borderRightWidth == null) { borderRightWidth = new BorderRightWidth(extractedWidths[0]); borderRightWidth.setStateChangeInformer(this); borderRightWidth.setAlreadyInUse(true); } else { borderRightWidth.setCssValue(extractedWidths[0]); } if (borderBottomWidth == null) { borderBottomWidth = new BorderBottomWidth( extractedWidths[0]); borderBottomWidth.setStateChangeInformer(this); borderBottomWidth.setAlreadyInUse(true); } else { borderBottomWidth.setCssValue(extractedWidths[0]); } if (borderLeftWidth == null) { borderLeftWidth = new BorderLeftWidth(extractedWidths[0]); borderLeftWidth.setStateChangeInformer(this); borderLeftWidth.setAlreadyInUse(true); } else { borderLeftWidth.setCssValue(extractedWidths[0]); } } else if (extractedWidths.length == 2) { if (borderTopWidth == null) { borderTopWidth = new BorderTopWidth(extractedWidths[0]); borderTopWidth.setStateChangeInformer(this); borderTopWidth.setAlreadyInUse(true); } else { borderTopWidth.setCssValue(extractedWidths[0]); } if (borderBottomWidth == null) { borderBottomWidth = new BorderBottomWidth( extractedWidths[0]); borderBottomWidth.setStateChangeInformer(this); borderBottomWidth.setAlreadyInUse(true); } else { borderBottomWidth.setCssValue(extractedWidths[0]); } if (borderRightWidth == null) { borderRightWidth = new BorderRightWidth(extractedWidths[1]); borderRightWidth.setStateChangeInformer(this); borderRightWidth.setAlreadyInUse(true); } else { borderRightWidth.setCssValue(extractedWidths[1]); } if (borderLeftWidth == null) { borderLeftWidth = new BorderLeftWidth(extractedWidths[1]); borderLeftWidth.setStateChangeInformer(this); borderLeftWidth.setAlreadyInUse(true); } else { borderLeftWidth.setCssValue(extractedWidths[1]); } } else if (extractedWidths.length == 3) { if (borderTopWidth == null) { borderTopWidth = new BorderTopWidth(extractedWidths[0]); borderTopWidth.setStateChangeInformer(this); borderTopWidth.setAlreadyInUse(true); } else { borderTopWidth.setCssValue(extractedWidths[0]); } if (borderRightWidth == null) { borderRightWidth = new BorderRightWidth(extractedWidths[1]); borderRightWidth.setStateChangeInformer(this); borderRightWidth.setAlreadyInUse(true); } else { borderRightWidth.setCssValue(extractedWidths[1]); } if (borderLeftWidth == null) { borderLeftWidth = new BorderLeftWidth(extractedWidths[1]); borderLeftWidth.setStateChangeInformer(this); borderLeftWidth.setAlreadyInUse(true); } else { borderLeftWidth.setCssValue(extractedWidths[1]); } if (borderBottomWidth == null) { borderBottomWidth = new BorderBottomWidth( extractedWidths[2]); borderBottomWidth.setStateChangeInformer(this); borderBottomWidth.setAlreadyInUse(true); } else { borderBottomWidth.setCssValue(extractedWidths[2]); } } else if (extractedWidths.length == 4) { if (borderTopWidth == null) { borderTopWidth = new BorderTopWidth(extractedWidths[0]); borderTopWidth.setStateChangeInformer(this); borderTopWidth.setAlreadyInUse(true); } else { borderTopWidth.setCssValue(extractedWidths[0]); } if (borderRightWidth == null) { borderRightWidth = new BorderRightWidth(extractedWidths[1]); borderRightWidth.setStateChangeInformer(this); borderRightWidth.setAlreadyInUse(true); } else { borderRightWidth.setCssValue(extractedWidths[1]); } if (borderBottomWidth == null) { borderBottomWidth = new BorderBottomWidth( extractedWidths[2]); borderBottomWidth.setStateChangeInformer(this); borderBottomWidth.setAlreadyInUse(true); } else { borderBottomWidth.setCssValue(extractedWidths[2]); } if (borderLeftWidth == null) { borderLeftWidth = new BorderLeftWidth(extractedWidths[3]); borderLeftWidth.setStateChangeInformer(this); borderLeftWidth.setAlreadyInUse(true); } else { borderLeftWidth.setCssValue(extractedWidths[3]); } } else { throw new InvalidValueException( "the given cssValue is invalid"); } this.cssValue = borderWidthString; if (getStateChangeInformer() != null) { getStateChangeInformer().stateChanged(this); } } return this; } 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 testSetCssValue() { BorderWidth borderWidth = new BorderWidth(); borderWidth.setCssValue("75px"); assertEquals("75px", borderWidth.getCssValue()); }