Padding extends AbstractCssProperty<Padding> implements StateChangeInformer<CssProperty> { public void setPadding(final PaddingTop paddingTop, final PaddingRight paddingRight, final PaddingBottom paddingBottom, final PaddingLeft paddingLeft) { if (paddingTop != null && paddingRight != null && paddingBottom != null && paddingLeft != null) { if (PaddingTop.INITIAL.equals(paddingTop.getCssValue()) || PaddingTop.INHERIT.equals(paddingTop.getCssValue()) || PaddingRight.INITIAL.equals(paddingRight.getCssValue()) || PaddingRight.INHERIT.equals(paddingRight.getCssValue()) || PaddingBottom.INITIAL.equals(paddingBottom.getCssValue()) || PaddingBottom.INHERIT.equals(paddingBottom.getCssValue()) || PaddingLeft.INITIAL.equals(paddingLeft.getCssValue()) || PaddingLeft.INHERIT.equals(paddingLeft.getCssValue())) { throw new InvalidValueException( "Any or all of the given arguments have initial/inherit constant value as its cssValue"); } try { final PaddingTop paddingTopTemp; final PaddingRight paddingRightTemp; final PaddingBottom paddingBottomTemp; final PaddingLeft paddingLeftTemp; if (this.paddingTop != null) { this.paddingTop.setAlreadyInUse(false); this.paddingRight.setAlreadyInUse(false); this.paddingBottom.setAlreadyInUse(false); this.paddingLeft.setAlreadyInUse(false); } if (paddingTop.isAlreadyInUse() && this.paddingTop != paddingTop) { if (this.paddingTop != null) { paddingTopTemp = this.paddingTop .setCssValue(paddingTop.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given paddingTop is already used by another object so the existing object is used"); } } else { paddingTopTemp = paddingTop.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given paddingTop is already used by another object so its clone is assigned"); } } } else { paddingTopTemp = paddingTop; } if (paddingRight.isAlreadyInUse() && this.paddingRight != paddingRight) { if (this.paddingRight != null) { paddingRightTemp = this.paddingRight .setCssValue(paddingTop.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given paddingRight is already used by another object so the existing object is used"); } } else { paddingRightTemp = paddingRight.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given paddingRight is already used by another object so its clone is assigned"); } } } else { paddingRightTemp = paddingRight; } if (paddingBottom.isAlreadyInUse() && this.paddingBottom != paddingBottom) { if (this.paddingBottom != null) { paddingBottomTemp = this.paddingBottom .setCssValue(paddingTop.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given paddingBottom is already used by another object so the existing object is used"); } } else { paddingBottomTemp = paddingBottom.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given paddingBottom is already used by another object so its clone is assigned"); } } } else { paddingBottomTemp = paddingBottom; } if (paddingLeft.isAlreadyInUse() && this.paddingLeft != paddingLeft) { if (this.paddingLeft != null) { paddingLeftTemp = this.paddingLeft .setCssValue(paddingTop.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given paddingLeft is already used by another object so the existing object is used"); } } else { paddingLeftTemp = paddingLeft.clone(); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given paddingLeft is already used by another object so its clone is assigned"); } } } else { paddingLeftTemp = paddingLeft; } paddingTopTemp.setAlreadyInUse(true); paddingTopTemp.setStateChangeInformer(this); paddingRightTemp.setAlreadyInUse(true); paddingRightTemp.setStateChangeInformer(this); paddingBottomTemp.setAlreadyInUse(true); paddingBottomTemp.setStateChangeInformer(this); paddingLeftTemp.setAlreadyInUse(true); paddingLeftTemp.setStateChangeInformer(this); assignProducedCssValue(paddingTop, paddingRight, paddingBottom, paddingLeft); this.paddingTop = paddingTopTemp; this.paddingRight = paddingRightTemp; this.paddingBottom = paddingBottomTemp; this.paddingLeft = paddingLeftTemp; } catch (final CloneNotSupportedException e) { throw new InvalidValueException(e); } catch (final Exception e) { throw new InvalidValueException(e); } } else { throw new NullValueException("cannot accept null arguments"); } } Padding();  Padding(final String cssValue);  Padding(final Padding paddingBottom); Padding setValue(final String value); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); String getValue(); @Override Padding setCssValue(final String cssValue); void setAsInitial(); void setAsInherit(); PaddingTop getPaddingTop(); void setPadding(final PaddingTop paddingTop,
            final PaddingRight paddingRight, final PaddingBottom paddingBottom,
            final PaddingLeft paddingLeft); PaddingRight getPaddingRight(); PaddingBottom getPaddingBottom(); PaddingLeft getPaddingLeft(); @Override void stateChanged(final CssProperty stateChangedObject); boolean hasPredefinedConstantValue(); static boolean isValid(final String cssValue); static final String INITIAL; static final String INHERIT; }
@Test(expected = NullValueException.class) public void testSetPaddingForNullValues() { Padding padding = new Padding(); PaddingTop paddingTop = new PaddingTop("55px"); PaddingRight paddingRight = new PaddingRight("65px"); PaddingBottom paddingBottom = new PaddingBottom("75px"); PaddingLeft paddingLeft = new PaddingLeft("85px"); try { padding.setPadding(null, null, null, null); } catch (NullValueException e) { try { padding.setPadding(null, paddingRight, paddingBottom, paddingLeft); } catch (NullValueException e2) { try { padding.setPadding(paddingTop, null, paddingBottom, paddingLeft); } catch (NullValueException e3) { try { padding.setPadding(paddingTop, paddingRight, null, paddingLeft); } catch (NullValueException e4) { try { padding.setPadding(paddingTop, paddingRight, paddingBottom, null); } catch (NullValueException e5) { throw e4; } } } } } }