Columns extends AbstractCssProperty<Columns> implements StateChangeInformer<CssProperty> { public Columns setColumnCount(final ColumnCount columnCount) { final StringBuilder cssValueBuilder = new StringBuilder(); if (columnWidth != null) { final String columnWidthCssValue = columnWidth.getCssValue(); cssValueBuilder.append(columnWidthCssValue).append(' '); } if (columnCount != null) { final String columnWidthCssValue = columnCount.getCssValue(); if (ColumnCount.INITIAL.equals(columnWidthCssValue) || ColumnCount.INHERIT.equals(columnWidthCssValue)) { throw new InvalidValueException( "columnWidth cannot have initial/inherit as its cssValue"); } cssValueBuilder.append(columnWidthCssValue); } final String trimmedCssValue = StringBuilderUtil .getTrimmedString(cssValueBuilder); cssValue = trimmedCssValue.isEmpty() ? INHERIT : trimmedCssValue; if (columnCount != null && columnCount.isAlreadyInUse() && this.columnCount != columnCount) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "the given columnCount is already used by another object so a new object or the previous object (if it exists) of ColumnWidth will be used"); } return setCssValue(cssValue); } if (this.columnCount != null) { this.columnCount.setAlreadyInUse(false); } this.columnCount = columnCount; if (this.columnCount != null) { this.columnCount.setStateChangeInformer(this); this.columnCount.setAlreadyInUse(true); } if (getStateChangeInformer() != null) { getStateChangeInformer().stateChanged(this); } return this; } Columns();  Columns(final String cssValue);  Columns(final Columns columns); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); @Override Columns setCssValue(final String cssValue); static boolean isValid(final String cssValue); void setAsInitial(); void setAsInherit(); ColumnWidth getColumnWidth(); ColumnCount getColumnCount(); Columns setColumnWidth(final ColumnWidth columnWidth); Columns setColumnCount(final ColumnCount columnCount); @Override void stateChanged(final CssProperty stateChangedObject); static final String INITIAL; static final String INHERIT; }
@Test public void testSetColumnCount() { try { Columns columns = new Columns(); columns.setCssValue("55px 5"); columns.setColumnCount(new ColumnCount("2")); assertEquals("55px 2", columns.getCssValue()); assertNotNull(columns.getColumnCount()); assertEquals("2", columns.getColumnCount().getCssValue()); } catch (Exception e) { e.printStackTrace(); fail("testSetCssValueString failed"); } }