BorderWidth extends AbstractCssProperty<BorderWidth> implements StateChangeInformer<CssProperty> { public void setBorderWidth(final BorderTopWidth borderTopWidth, final BorderRightWidth borderRightWidth, final BorderBottomWidth borderBottomWidth, final BorderLeftWidth borderLeftWidth) { if (borderTopWidth != null && borderRightWidth != null && borderBottomWidth != null && borderLeftWidth != null) { if (BorderTopWidth.INITIAL.equals(borderTopWidth.getCssValue()) || BorderTopWidth.INHERIT .equals(borderTopWidth.getCssValue()) || BorderRightWidth.INITIAL .equals(borderRightWidth.getCssValue()) || BorderRightWidth.INHERIT .equals(borderRightWidth.getCssValue()) || BorderBottomWidth.INITIAL .equals(borderBottomWidth.getCssValue()) || BorderBottomWidth.INHERIT .equals(borderBottomWidth.getCssValue()) || BorderLeftWidth.INITIAL .equals(borderLeftWidth.getCssValue()) || BorderLeftWidth.INHERIT .equals(borderLeftWidth.getCssValue())) { throw new InvalidValueException( "Any or all of the given arguments have initial/inherit constant value as its cssValue"); } try { final BorderTopWidth borderTopWidthTemp; final BorderRightWidth borderRightWidthTemp; final BorderBottomWidth borderBottomWidthTemp; final BorderLeftWidth borderLeftWidthTemp; if (this.borderTopWidth != null) { this.borderTopWidth.setAlreadyInUse(false); this.borderRightWidth.setAlreadyInUse(false); this.borderBottomWidth.setAlreadyInUse(false); this.borderLeftWidth.setAlreadyInUse(false); } if (borderTopWidth.isAlreadyInUse() && this.borderTopWidth != borderTopWidth) { if (this.borderTopWidth != null) { borderTopWidthTemp = this.borderTopWidth .setCssValue(borderTopWidth.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderTopWidth is already used by another object so the existing object is used"); } } else { borderTopWidthTemp = borderTopWidth.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderTopWidth is already used by another object so its clone is assigned"); } } } else { borderTopWidthTemp = borderTopWidth; } if (borderRightWidth.isAlreadyInUse() && this.borderRightWidth != borderRightWidth) { if (this.borderRightWidth != null) { borderRightWidthTemp = this.borderRightWidth .setCssValue(borderTopWidth.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderRightWidth is already used by another object so the existing object is used"); } } else { borderRightWidthTemp = borderRightWidth.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderRightWidth is already used by another object so its clone is assigned"); } } } else { borderRightWidthTemp = borderRightWidth; } if (borderBottomWidth.isAlreadyInUse() && this.borderBottomWidth != borderBottomWidth) { if (this.borderBottomWidth != null) { borderBottomWidthTemp = this.borderBottomWidth .setCssValue(borderTopWidth.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderBottomWidth is already used by another object so the existing object is used"); } } else { borderBottomWidthTemp = borderBottomWidth.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderBottomWidth is already used by another object so its clone is assigned"); } } } else { borderBottomWidthTemp = borderBottomWidth; } if (borderLeftWidth.isAlreadyInUse() && this.borderLeftWidth != borderLeftWidth) { if (this.borderLeftWidth != null) { borderLeftWidthTemp = this.borderLeftWidth .setCssValue(borderTopWidth.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderLeftWidth is already used by another object so the existing object is used"); } } else { borderLeftWidthTemp = borderLeftWidth.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderLeftWidth is already used by another object so its clone is assigned"); } } } else { borderLeftWidthTemp = borderLeftWidth; } borderTopWidthTemp.setAlreadyInUse(true); borderTopWidthTemp.setStateChangeInformer(this); borderRightWidthTemp.setAlreadyInUse(true); borderRightWidthTemp.setStateChangeInformer(this); borderBottomWidthTemp.setAlreadyInUse(true); borderBottomWidthTemp.setStateChangeInformer(this); borderLeftWidthTemp.setAlreadyInUse(true); borderLeftWidthTemp.setStateChangeInformer(this); assignProducedCssValue(borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth); this.borderTopWidth = borderTopWidthTemp; this.borderRightWidth = borderRightWidthTemp; this.borderBottomWidth = borderBottomWidthTemp; this.borderLeftWidth = borderLeftWidthTemp; } catch (final CloneNotSupportedException e) { throw new InvalidValueException(e); } catch (final Exception e) { throw new InvalidValueException(e); } } else { throw new NullValueException("cannot accept null arguments"); } } 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(expected = NullValueException.class) public void testSetBorderWidthForNullValues() { BorderWidth borderWidth = new BorderWidth(); BorderTopWidth borderTopWidth = new BorderTopWidth("25px"); BorderRightWidth borderRightWidth = new BorderRightWidth("45px"); BorderBottomWidth borderBottomWidth = new BorderBottomWidth("85px"); BorderLeftWidth borderLeftWidth = new BorderLeftWidth("155px"); try { borderWidth.setBorderWidth(null, null, null, null); } catch (NullValueException e) { try { borderWidth.setBorderWidth(null, borderRightWidth, borderBottomWidth, borderLeftWidth); } catch (NullValueException e2) { try { borderWidth.setBorderWidth(borderTopWidth, null, borderBottomWidth, borderLeftWidth); } catch (NullValueException e3) { try { borderWidth.setBorderWidth(borderTopWidth, borderRightWidth, null, borderLeftWidth); } catch (NullValueException e4) { try { borderWidth.setBorderWidth(borderTopWidth, borderRightWidth, borderBottomWidth, null); } catch (NullValueException e5) { throw e4; } } } } } }