@Override
    public Outline setCssValue(final String cssValue) {
        final String trimmedCssValue;
        if (cssValue == null) {
            throw new NullValueException(
                    "null is an invalid value. The value format should be as for example medium none color Or initial/inherit.");
        } else if ((trimmedCssValue = TagStringUtil
                .toLowerCase(StringUtil.strip(cssValue))).isEmpty()) {
            throw new NullValueException(cssValue
                    + " is an invalid value. The value format should be as for example medium none color Or initial/inherit.");
        }

        final List<String> cssValueParts = CssValueUtil.split(trimmedCssValue);

        if (cssValueParts.size() > 1) {
            if (trimmedCssValue.contains(OutlineColor.INITIAL)) {
                throw new InvalidValueException(
                        "The string 'initial' makes the given cssValue invalid, please remove 'initial' from it and try.");
            }
            if (trimmedCssValue.contains(OutlineColor.INHERIT)) {
                throw new InvalidValueException(
                        "The string 'inherit' makes the given cssValue invalid, please remove 'inherit' from it and try.");
            }
        } else {
            if (PREDEFINED_CONSTANTS.contains(trimmedCssValue)) {
                if (outlineColor != null) {
                    outlineColor.setAlreadyInUse(false);
                    outlineColor = null;
                }

                outlineStyle = null;

                if (outlineWidth != null) {
                    outlineWidth.setAlreadyInUse(false);
                    outlineWidth = null;
                }

                this.cssValue = trimmedCssValue;
                if (getStateChangeInformer() != null) {
                    getStateChangeInformer().stateChanged(this);
                }
                return this;
            }
        }

        OutlineColor outlineColor = null;
        OutlineStyle outlineStyle = null;
        OutlineWidth outlineWidth = null;

        for (final String eachPart : cssValueParts) {
            if (outlineColor == null && OutlineColor.isValid(eachPart)) {
                if (this.outlineColor == null) {
                    outlineColor = new OutlineColor(eachPart);
                    outlineColor.setStateChangeInformer(this);
                    outlineColor.setAlreadyInUse(true);
                } else {
                    this.outlineColor.setCssValue(eachPart);
                    outlineColor = this.outlineColor;
                }
            } else if (outlineStyle == null && OutlineStyle.isValid(eachPart)) {
                outlineStyle = OutlineStyle.getThis(eachPart);
            } else if (outlineWidth == null && OutlineWidth.isValid(eachPart)) {
                if (this.outlineWidth == null) {
                    outlineWidth = new OutlineWidth(eachPart);
                    outlineWidth.setStateChangeInformer(this);
                    outlineWidth.setAlreadyInUse(true);
                } else {
                    this.outlineWidth.setCssValue(eachPart);
                    outlineWidth = this.outlineWidth;
                }
            }
        }

        final StringBuilder cssValueBuilder = new StringBuilder();
        boolean invalid = true;

        if (outlineColor != null) {
            cssValueBuilder.append(outlineColor.getCssValue()).append(' ');
            invalid = false;
        } else if (this.outlineColor != null) {
            this.outlineColor.setAlreadyInUse(false);
        }

        if (outlineStyle != null) {
            cssValueBuilder.append(outlineStyle.getCssValue()).append(' ');
            invalid = false;
        }

        if (outlineWidth != null) {
            cssValueBuilder.append(outlineWidth.getCssValue()).append(' ');
            invalid = false;
        } else if (this.outlineWidth != null) {
            this.outlineWidth.setAlreadyInUse(false);
        }

        if (invalid) {
            throw new InvalidValueException(cssValue
                    + " is an invalid value. The value format should be as for example medium none color Or initial/inherit.");
        }
        this.cssValue = StringBuilderUtil.getTrimmedString(cssValueBuilder);
        this.outlineColor = outlineColor;
        this.outlineWidth = outlineWidth;
        this.outlineStyle = outlineStyle;

        if (getStateChangeInformer() != null) {
            getStateChangeInformer().stateChanged(this);
        }

        return this;
    }
@ Override public Outline setCssValue ( final String cssValue ) { final String trimmedCssValue ; if ( cssValue == null ) { throw new NullValueException ( "null is an invalid value. The value format should be as for example medium none color Or initial/inherit." ) ; } else if ( ( trimmedCssValue = TagStringUtil . toLowerCase ( StringUtil . strip ( cssValue ) ) ) . isEmpty ( ) ) { throw new NullValueException ( cssValue + " is an invalid value. The value format should be as for example medium none color Or initial/inherit." ) ; } final List < String > cssValueParts = CssValueUtil . split ( trimmedCssValue ) ; if ( cssValueParts . size ( ) > 1 ) { if ( trimmedCssValue . contains ( OutlineColor . INITIAL ) ) { throw new InvalidValueException ( "The string 'initial' makes the given cssValue invalid, please remove 'initial' from it and try." ) ; } if ( trimmedCssValue . contains ( OutlineColor . INHERIT ) ) { throw new InvalidValueException ( "The string 'inherit' makes the given cssValue invalid, please remove 'inherit' from it and try." ) ; } } else { if ( PREDEFINED_CONSTANTS . contains ( trimmedCssValue ) ) { if ( outlineColor != null ) { outlineColor . setAlreadyInUse ( false ) ; outlineColor = null ; } outlineStyle = null ; if ( outlineWidth != null ) { outlineWidth . setAlreadyInUse ( false ) ; outlineWidth = null ; } this . cssValue = trimmedCssValue ; if ( getStateChangeInformer ( ) != null ) { getStateChangeInformer ( ) . stateChanged ( this ) ; } return this ; } } OutlineColor outlineColor = null ; OutlineStyle outlineStyle = null ; OutlineWidth outlineWidth = null ; for ( final String eachPart : cssValueParts ) { if ( outlineColor == null && OutlineColor . isValid ( eachPart ) ) { if ( this . outlineColor == null ) { outlineColor = new OutlineColor ( eachPart ) ; outlineColor . setStateChangeInformer ( this ) ; outlineColor . setAlreadyInUse ( true ) ; } else { this . outlineColor . setCssValue ( eachPart ) ; outlineColor = this . outlineColor ; } } else if ( outlineStyle == null && OutlineStyle . isValid ( eachPart ) ) { outlineStyle = OutlineStyle . getThis ( eachPart ) ; } else if ( outlineWidth == null && OutlineWidth . isValid ( eachPart ) ) { if ( this . outlineWidth == null ) { outlineWidth = new OutlineWidth ( eachPart ) ; outlineWidth . setStateChangeInformer ( this ) ; outlineWidth . setAlreadyInUse ( true ) ; } else { this . outlineWidth . setCssValue ( eachPart ) ; outlineWidth = this . outlineWidth ; } } } final StringBuilder cssValueBuilder = new StringBuilder ( ) ; boolean invalid = true ; if ( outlineColor != null ) { cssValueBuilder . append ( outlineColor . getCssValue ( ) ) . append ( ' ' ) ; invalid = false ; } else if ( this . outlineColor != null ) { this . outlineColor . setAlreadyInUse ( false ) ; } if ( outlineStyle != null ) { cssValueBuilder . append ( outlineStyle . getCssValue ( ) ) . append ( ' ' ) ; invalid = false ; } if ( outlineWidth != null ) { cssValueBuilder . append ( outlineWidth . getCssValue ( ) ) . append ( ' ' ) ; invalid = false ; } else if ( this . outlineWidth != null ) { this . outlineWidth . setAlreadyInUse ( false ) ; } if ( invalid ) { throw new InvalidValueException ( cssValue + " is an invalid value. The value format should be as for example medium none color Or initial/inherit." ) ; } this . cssValue = StringBuilderUtil . getTrimmedString ( cssValueBuilder ) ; this . outlineColor = outlineColor ; this . outlineWidth = outlineWidth ; this . outlineStyle = outlineStyle ; if ( getStateChangeInformer ( ) != null ) { getStateChangeInformer ( ) . stateChanged ( this ) ; } return this ; }
@param cssValue
the value should be in the format of
<code>medium none color</code>, <code>initial</code>
or <code>inherit</code>. {@code null} is considered
as an invalid value and it will throw
{@code NullValueException}.
@since 1.0.0
@author WFF