MozFlex extends AbstractCssProperty<MozFlex> implements StateChangeInformer<CssProperty> { public MozFlex setMozFlexBasis(final MozFlexBasis mozFlexBasis) { if (mozFlexBasis == null) { throw new InvalidValueException("mozFlexBasis cannot be null"); } if (Objects.equals(this.mozFlexBasis, mozFlexBasis)) { return this; } final StringBuilder cssValueBuilder = new StringBuilder(); if (mozFlexGrow == null) { mozFlexGrow = new MozFlexGrow(1); mozFlexGrow.setStateChangeInformer(this); mozFlexGrow.setAlreadyInUse(true); } cssValueBuilder.append(mozFlexGrow.getCssValue()).append(' '); if (mozFlexShrink == null) { mozFlexShrink = new MozFlexShrink(1); mozFlexShrink.setStateChangeInformer(this); mozFlexShrink.setAlreadyInUse(true); } cssValueBuilder.append(mozFlexShrink.getCssValue()).append(' '); if (this.mozFlexBasis != null) { this.mozFlexBasis.setCssValue(mozFlexBasis.getCssValue()); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "copied the cssValue from the given mozFlexBasis to the existing mozFlexBasis object."); } } else { if (mozFlexBasis.isAlreadyInUse()) { this.mozFlexBasis = new MozFlexBasis(mozFlexBasis); this.mozFlexBasis.setAlreadyInUse(true); this.mozFlexBasis.setStateChangeInformer(this); if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "created a new object of MozFlexBasis as the given mozFlexBasis object is already used by another object"); } } else { this.mozFlexBasis = mozFlexBasis; this.mozFlexBasis.setAlreadyInUse(true); this.mozFlexBasis.setStateChangeInformer(this); } } 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 testSetMozFlexBasis() { final MozFlex flex = new MozFlex("6 5 25px"); final MozFlexBasis flexBasis1 = flex.getMozFlexBasis(); final MozFlexBasis flexBasis2 = new MozFlexBasis(2, CssLengthUnit.PX); flex.setMozFlexBasis(flexBasis2); assertEquals("6.0 5.0 2.0px", flex.getCssValue()); assertNotNull(flex.getMozFlexGrow()); assertEquals("6.0", flex.getMozFlexGrow().getCssValue()); assertNotNull(flex.getMozFlexShrink()); assertEquals("5.0", flex.getMozFlexShrink().getCssValue()); assertNotNull(flex.getMozFlexBasis()); assertEquals("2.0px", flex.getMozFlexBasis().getCssValue()); assertNotEquals(flexBasis1, flexBasis2); assertNotEquals(flexBasis2, flex.getMozFlexBasis()); assertEquals(flexBasis1, flex.getMozFlexBasis()); flex.setMozFlexBasis(flexBasis1); }