Flex extends AbstractCssProperty<Flex> implements StateChangeInformer<CssProperty> { public static boolean isValid(final String cssValue) { if (cssValue == null || StringUtil.isBlank(cssValue)) { return false; } final String[] cssValueParts = StringUtil.splitBySpace(cssValue); FlexGrow flexGrow = null; FlexShrink flexShrink = null; FlexBasis flexBasis = null; for (final String eachPart : cssValueParts) { boolean invalid = true; if (flexGrow == null && FlexGrow.isValid(eachPart)) { flexGrow = new FlexGrow(eachPart); invalid = false; } else if (flexShrink == null && FlexShrink.isValid(eachPart)) { flexShrink = new FlexShrink(eachPart); invalid = false; } else if (flexBasis == null && FlexBasis.isValid(eachPart)) { flexBasis = new FlexBasis(eachPart); invalid = false; } if (invalid) { return false; } } return flexGrow != null || flexShrink != null || flexBasis != null; } Flex();  Flex(final String cssValue);  Flex(final Flex flex); @Override String getCssName(); @Override String getCssValue(); @Override String toString(); @Override Flex setCssValue(final String cssValue); static boolean isValid(final String cssValue); void setAsInitial(); void setAsInherit(); void setAsAuto(); FlexBasis getFlexBasis(); FlexShrink getFlexShrink(); FlexGrow getFlexGrow(); Flex setFlexGrow(final FlexGrow flexGrow); Flex setFlexShrink(final FlexShrink flexShrink); Flex setFlexBasis(final FlexBasis flexBasis); @Override void stateChanged(final CssProperty stateChangedObject); static final String INITIAL; static final String INHERIT; static final String AUTO; }
@Test public void testIsValid() { assertTrue(Flex.isValid("1")); assertTrue(Flex.isValid("1px")); assertTrue(Flex.isValid("1 1")); assertTrue(Flex.isValid("1 2 3px")); assertFalse(Flex.isValid("1 2 3")); assertFalse(Flex.isValid("1 df")); assertFalse(Flex.isValid("kdfidk")); assertFalse(Flex.isValid("1 2 2 2")); }