Outline extends AbstractCssProperty<Outline> implements StateChangeInformer<CssProperty> { public Outline setOutlineColor(final OutlineColor outlineColor) { final StringBuilder cssValueBuilder = new StringBuilder(); if (outlineColor != null) { final String outlineColorCssValue = outlineColor.getCssValue(); if (OutlineColor.INITIAL.equals(outlineColorCssValue) || OutlineColor.INHERIT.equals(outlineColorCssValue)) { throw new InvalidValueException( "outlineColor cannot have initial/inherit as its cssValue"); } cssValueBuilder.append(outlineColorCssValue).append(' '); } if (outlineStyle != null) { cssValueBuilder.append(outlineStyle.getCssValue()).append(' '); } if (outlineWidth != null) { cssValueBuilder.append(outlineWidth.getCssValue()); } final String trimmedCssValue = StringBuilderUtil .getTrimmedString(cssValueBuilder).toString(); cssValue = trimmedCssValue.isEmpty() ? INHERIT : trimmedCssValue; if (outlineColor != null && outlineColor.isAlreadyInUse() && this.outlineColor != outlineColor) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given outlineColor is already used by another object so a new object or the previous object (if it exists) of OutlineColor will be used"); } return setCssValue(cssValue); } if (this.outlineColor != null) { this.outlineColor.setAlreadyInUse(false); } this.outlineColor = outlineColor; if (this.outlineColor != null) { this.outlineColor.setStateChangeInformer(this); this.outlineColor.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 testSetOutlineColor() { Outline border = new Outline(); border.setCssValue("green solid thick"); assertEquals("green solid thick", border.getCssValue()); final OutlineColor outlineColor = border.getOutlineColor(); assertTrue(outlineColor.isAlreadyInUse()); assertEquals("green", outlineColor.getCssValue()); border.setOutlineColor(new OutlineColor("blue")); assertEquals("blue solid thick", border.getCssValue()); border.setCssValue("solid thick"); assertNull(border.getOutlineColor()); assertFalse(outlineColor.isAlreadyInUse()); assertEquals("solid thick", border.getCssValue()); }
@Test(expected = InvalidValueException.class) public void testSetOutlineColorInvalidValue() { Outline border = new Outline(); border.setOutlineColor(new OutlineColor(OutlineColor.INITIAL)); }