BorderColor extends AbstractCssProperty<BorderColor> implements StateChangeInformer<CssProperty> { public void setBorderColor(final BorderTopColor borderTopColor, final BorderRightColor borderRightColor, final BorderBottomColor borderBottomColor, final BorderLeftColor borderLeftColor) { if (borderTopColor != null && borderRightColor != null && borderBottomColor != null && borderLeftColor != null) { if (BorderTopColor.INITIAL.equals(borderTopColor.getCssValue()) || BorderTopColor.INHERIT .equals(borderTopColor.getCssValue()) || BorderRightColor.INITIAL .equals(borderRightColor.getCssValue()) || BorderRightColor.INHERIT .equals(borderRightColor.getCssValue()) || BorderBottomColor.INITIAL .equals(borderBottomColor.getCssValue()) || BorderBottomColor.INHERIT .equals(borderBottomColor.getCssValue()) || BorderLeftColor.INITIAL .equals(borderLeftColor.getCssValue()) || BorderLeftColor.INHERIT .equals(borderLeftColor.getCssValue())) { throw new InvalidValueException( "Any or all of the given arguments have initial/inherit constant value as its cssValue"); } try { final BorderTopColor borderTopColorTemp; final BorderRightColor borderRightColorTemp; final BorderBottomColor borderBottomColorTemp; final BorderLeftColor borderLeftColorTemp; if (this.borderTopColor != null) { assignProducedCssValue(borderTopColor, borderRightColor, borderBottomColor, borderLeftColor); this.borderTopColor.setAlreadyInUse(false); this.borderRightColor.setAlreadyInUse(false); this.borderBottomColor.setAlreadyInUse(false); this.borderLeftColor.setAlreadyInUse(false); borderTopColorTemp = borderTopColor; borderRightColorTemp = borderRightColor; borderBottomColorTemp = borderBottomColor; borderLeftColorTemp = borderLeftColor; } else { if (borderTopColor.isAlreadyInUse()) { borderTopColorTemp = borderTopColor.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderTopColor is already used by another object so its clone is assigned"); } } else { borderTopColorTemp = borderTopColor; } if (borderRightColor.isAlreadyInUse()) { borderRightColorTemp = borderRightColor.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderRightColor is already used by another object so its clone is assigned"); } } else { borderRightColorTemp = borderRightColor; } if (borderBottomColor.isAlreadyInUse()) { borderBottomColorTemp = borderBottomColor.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderBottomColor is already used by another object so its clone is assigned"); } } else { borderBottomColorTemp = borderBottomColor; } if (borderLeftColor.isAlreadyInUse()) { borderLeftColorTemp = borderLeftColor.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given borderLeftColor is already used by another object so its clone is assigned"); } } else { borderLeftColorTemp = borderLeftColor; } } borderTopColorTemp.setAlreadyInUse(true); borderTopColorTemp.setStateChangeInformer(this); borderRightColorTemp.setAlreadyInUse(true); borderRightColorTemp.setStateChangeInformer(this); borderBottomColorTemp.setAlreadyInUse(true); borderBottomColorTemp.setStateChangeInformer(this); borderLeftColorTemp.setAlreadyInUse(true); borderLeftColorTemp.setStateChangeInformer(this); assignProducedCssValue(borderTopColor, borderRightColor, borderBottomColor, borderLeftColor); this.borderTopColor = borderTopColorTemp; this.borderRightColor = borderRightColorTemp; this.borderBottomColor = borderBottomColorTemp; this.borderLeftColor = borderLeftColorTemp; } catch (final CloneNotSupportedException e) { throw new InvalidValueException(e); } catch (final Exception e) { throw new InvalidValueException(e); } } else { throw new NullValueException("cannot accept null arguments"); } } BorderColor();  BorderColor(final String cssValue);  BorderColor(final BorderColor borderBottomColor); BorderColor setValue(final String value); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); String getValue(); @Override BorderColor setCssValue(final String cssValue); void setAsInitial(); void setAsInherit(); void setAsTransparent(); BorderTopColor getBorderTopColor(); void setBorderColor(final BorderTopColor borderTopColor,
            final BorderRightColor borderRightColor,
            final BorderBottomColor borderBottomColor,
            final BorderLeftColor borderLeftColor); BorderRightColor getBorderRightColor(); BorderBottomColor getBorderBottomColor(); BorderLeftColor getBorderLeftColor(); @Override void stateChanged(final CssProperty stateChangedObject); boolean hasPredefinedConstantValue(); static boolean isValid(final String cssValue); static final String INITIAL; static final String INHERIT; static final String TRANSPARENT; }
@Test(expected = NullValueException.class) public void testSetBorderColorForNullValues() { BorderColor borderColor = new BorderColor(); BorderTopColor borderTopColor = new BorderTopColor("red"); BorderRightColor borderRightColor = new BorderRightColor("green"); BorderBottomColor borderBottomColor = new BorderBottomColor("blue"); BorderLeftColor borderLeftColor = new BorderLeftColor("yellow"); try { borderColor.setBorderColor(null, null, null, null); } catch (NullValueException e) { try { borderColor.setBorderColor(null, borderRightColor, borderBottomColor, borderLeftColor); } catch (NullValueException e2) { try { borderColor.setBorderColor(borderTopColor, null, borderBottomColor, borderLeftColor); } catch (NullValueException e3) { try { borderColor.setBorderColor(borderTopColor, borderRightColor, null, borderLeftColor); } catch (NullValueException e4) { try { borderColor.setBorderColor(borderTopColor, borderRightColor, borderBottomColor, null); } catch (NullValueException e5) { throw e4; } } } } } }