MozFlex extends AbstractCssProperty<MozFlex> implements StateChangeInformer<CssProperty> { public static boolean isValid(final String cssValue) { if (cssValue == null || StringUtil.isBlank(cssValue)) { return false; } final String[] cssValueParts = StringUtil.splitBySpace(cssValue); MozFlexGrow mozFlexGrow = null; MozFlexShrink mozFlexShrink = null; MozFlexBasis mozFlexBasis = null; for (final String eachPart : cssValueParts) { boolean invalid = true; if (mozFlexGrow == null && MozFlexGrow.isValid(eachPart)) { mozFlexGrow = new MozFlexGrow(eachPart); invalid = false; } else if (mozFlexShrink == null && MozFlexShrink.isValid(eachPart)) { mozFlexShrink = new MozFlexShrink(eachPart); invalid = false; } else if (mozFlexBasis == null && MozFlexBasis.isValid(eachPart)) { mozFlexBasis = new MozFlexBasis(eachPart); invalid = false; } if (invalid) { return false; } } return mozFlexGrow != null || mozFlexShrink != null || mozFlexBasis != null; } 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 testIsValid() { assertTrue(MozFlex.isValid("1")); assertTrue(MozFlex.isValid("1px")); assertTrue(MozFlex.isValid("1 1")); assertTrue(MozFlex.isValid("1 2 3px")); assertFalse(MozFlex.isValid("1 2 3")); assertFalse(MozFlex.isValid("1 df")); assertFalse(MozFlex.isValid("kdfidk")); assertFalse(MozFlex.isValid("1 2 2 2")); }