Outline extends AbstractCssProperty<Outline> implements StateChangeInformer<CssProperty> { public Outline setOutlineWidth(final OutlineWidth outlineWidth) { final StringBuilder cssValueBuilder = new StringBuilder(); if (outlineColor != null) { cssValueBuilder.append(outlineColor.getCssValue()).append(' '); } if (outlineStyle != null) { cssValueBuilder.append(outlineStyle.getCssValue()).append(' '); } if (outlineWidth != null) { final String outlineWidthCssValue = outlineWidth.getCssValue(); if (OutlineWidth.INITIAL.equals(outlineWidthCssValue) || OutlineWidth.INHERIT.equals(outlineWidthCssValue)) { throw new InvalidValueException( "outlineWidth cannot have initial/inherit as its cssValue"); } cssValueBuilder.append(outlineWidth.getCssValue()); } final String trimmedCssValue = StringBuilderUtil .getTrimmedString(cssValueBuilder).toString(); cssValue = trimmedCssValue.isEmpty() ? INHERIT : trimmedCssValue; if (outlineWidth != null && outlineWidth.isAlreadyInUse() && this.outlineWidth != outlineWidth) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given outlineWidth is already used by another object so a new object or the previous object (if it exists) of OutlineWidth will be used"); } return setCssValue(cssValue); } if (this.outlineWidth != null) { this.outlineWidth.setAlreadyInUse(false); } this.outlineWidth = outlineWidth; if (this.outlineWidth != null) { this.outlineWidth.setStateChangeInformer(this); this.outlineWidth.setAlreadyInUse(true); } if (getStateChangeInformer() != null) { getStateChangeInformer().stateChanged(this); } return this; } Outline();  Outline(final String cssValue);  Outline(final Outline outline); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); @Override Outline setCssValue(final String cssValue); static boolean isValid(final String cssValue); void setAsInitial(); void setAsInherit(); OutlineColor getOutlineColor(); OutlineStyle getOutlineStyle(); OutlineWidth getOutlineWidth(); Outline setOutlineWidth(final OutlineWidth outlineWidth); Outline setOutlineStyle(final OutlineStyle outlineStyle); Outline setOutlineColor(final OutlineColor outlineColor); @Override void stateChanged(final CssProperty stateChangedObject); static final String INITIAL; static final String INHERIT; }
@Test public void testSetOutlineWidth() { Outline border = new Outline(); border.setCssValue("green solid thick"); assertEquals("green solid thick", border.getCssValue()); final OutlineWidth outlineWidth = border.getOutlineWidth(); assertTrue(outlineWidth.isAlreadyInUse()); assertEquals("thick", outlineWidth.getCssValue()); border.setOutlineWidth(new OutlineWidth(OutlineWidth.MEDIUM)); border.setCssValue("solid green"); assertNull(border.getOutlineWidth()); assertFalse(outlineWidth.isAlreadyInUse()); assertEquals("green solid", border.getCssValue()); }
@Test(expected = InvalidValueException.class) public void testSetOutlineWidthInvalidValue() { Outline border = new Outline(); border.setOutlineWidth(new OutlineWidth("initial")); }