MozFlex extends AbstractCssProperty<MozFlex> implements StateChangeInformer<CssProperty> { public MozFlex setMozFlexGrow(final MozFlexGrow mozFlexGrow) { if (mozFlexGrow == null) { throw new InvalidValueException("mozFlexGrow cannot be null"); } if (Objects.equals(this.mozFlexGrow, mozFlexGrow)) { return this; } final StringBuilder cssValueBuilder = new StringBuilder(); if (this.mozFlexGrow != null) { this.mozFlexGrow.setCssValue(mozFlexGrow.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "copied the cssValue from the given mozFlexGrow to the existing mozFlexGrow object."); } } else { if (mozFlexGrow.isAlreadyInUse()) { this.mozFlexGrow = new MozFlexGrow(mozFlexGrow); this.mozFlexGrow.setAlreadyInUse(true); this.mozFlexGrow.setStateChangeInformer(this); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "created a new object of MozFlexGrow as the given mozFlexGrow object is already used by another object"); } } else { this.mozFlexGrow = mozFlexGrow; this.mozFlexGrow.setAlreadyInUse(true); this.mozFlexGrow.setStateChangeInformer(this); } } cssValueBuilder.append(mozFlexGrow.getCssValue()).append(' '); if (mozFlexShrink == null) { mozFlexShrink = new MozFlexShrink(1); mozFlexShrink.setStateChangeInformer(this); mozFlexShrink.setAlreadyInUse(true); } cssValueBuilder.append(mozFlexShrink.getCssValue()).append(' '); if (mozFlexBasis == null) { mozFlexBasis = new MozFlexBasis(0); mozFlexBasis.setStateChangeInformer(this); mozFlexBasis.setAlreadyInUse(true); } cssValueBuilder.append(mozFlexBasis.getCssValue()); cssValue = cssValueBuilder.toString(); if (getStateChangeInformer() != null) { getStateChangeInformer().stateChanged(this); } return this; } MozFlex();  MozFlex(final String cssValue);  MozFlex(final MozFlex mozFlex); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); @Override MozFlex setCssValue(final String cssValue); static boolean isValid(final String cssValue); void setAsInitial(); void setAsInherit(); void setAsAuto(); MozFlexBasis getMozFlexBasis(); MozFlexShrink getMozFlexShrink(); MozFlexGrow getMozFlexGrow(); MozFlex setMozFlexGrow(final MozFlexGrow mozFlexGrow); MozFlex setMozFlexShrink(final MozFlexShrink mozFlexShrink); MozFlex setMozFlexBasis(final MozFlexBasis mozFlexBasis); @Override void stateChanged(final CssProperty stateChangedObject); static final String INITIAL; static final String INHERIT; static final String AUTO; }
@Test public void testSetMozFlexGrow() { final MozFlex flex = new MozFlex("6 5 25px"); final MozFlexGrow flexGrow1 = flex.getMozFlexGrow(); final MozFlexGrow flexGrow2 = new MozFlexGrow(2); flex.setMozFlexGrow(flexGrow2); assertEquals("2.0 5.0 25px", flex.getCssValue()); assertNotNull(flex.getMozFlexGrow()); assertEquals("2.0", flex.getMozFlexGrow().getCssValue()); assertNotNull(flex.getMozFlexShrink()); assertEquals("5.0", flex.getMozFlexShrink().getCssValue()); assertNotNull(flex.getMozFlexBasis()); assertEquals("25px", flex.getMozFlexBasis().getCssValue()); assertNotEquals(flexGrow1, flexGrow2); assertNotEquals(flexGrow2, flex.getMozFlexGrow()); assertEquals(flexGrow1, flex.getMozFlexGrow()); flex.setMozFlexGrow(flexGrow1); }