Class CSSDeclaration

    • Constructor Detail

      • CSSDeclaration

        public CSSDeclaration​(@Nonnull @Nonempty
                              String sProperty,
                              @Nonnull
                              CSSExpression aExpression)
        Constructor for non-important values.
        Parameters:
        sProperty - The name of the property. E.g. "color". May neither be null nor empty. The property value is automatically lowercased!
        aExpression - The value of the property. May not be null.
      • CSSDeclaration

        public CSSDeclaration​(@Nonnull @Nonempty
                              String sProperty,
                              @Nonnull
                              CSSExpression aExpression,
                              boolean bIsImportant)
        Constructor.
        Parameters:
        sProperty - The name of the property. E.g. "color". May neither be null nor empty. The property value is automatically lowercased!
        aExpression - The value of the property. May not be null.
        bIsImportant - true if it is important, false if not.
    • Method Detail

      • getProperty

        @Nonnull
        @Nonempty
        public final String getProperty()
        Returns:
        The property of this declaration (e.g. "color" or "margin-top"). The string is always lowercase. Never null.
      • hasProperty

        public final boolean hasProperty​(@Nonnull
                                         String sProperty)
        Check if this declaration has the specified property. The comparison is case insensitive!
        Parameters:
        sProperty - The property to check. May not be null.
        Returns:
        true if this declaration has the specified property.
        Since:
        6.0.0
        See Also:
        hasProperty(ECSSProperty)
      • hasProperty

        public final boolean hasProperty​(@Nonnull
                                         ECSSProperty eProperty)
        Check if this declaration has the specified property. The comparison is case insensitive!
        Parameters:
        eProperty - The property to check. May not be null.
        Returns:
        true if this declaration has the specified property.
        Since:
        6.0.0
        See Also:
        hasProperty(String)
      • setProperty

        @Nonnull
        public final CSSDeclaration setProperty​(@Nonnull @Nonempty
                                                String sProperty)
        Set the property of this CSS value (e.g. background-color).
        Parameters:
        sProperty - The CSS property name to set. May neither be null nor empty. The property value is automatically lowercased!
        Returns:
        this
        Since:
        3.7.4
      • setProperty

        @Nonnull
        public final CSSDeclaration setProperty​(@Nonnull
                                                ECSSProperty eProperty)
        Set the property of this CSS value (e.g. background-color).
        Parameters:
        eProperty - The CSS property to set. May not be null.
        Returns:
        this
        Since:
        3.7.4
      • getExpression

        @Nonnull
        @ReturnsMutableObject
        public final CSSExpression getExpression()
        Returns:
        The expression of this declaration (e.g. "red" or "25px" or "25px 10px 25px 9px") as a structured value. Never null.
      • getExpressionAsCSSString

        @Nonnull
        public final String getExpressionAsCSSString()
        Get the CSS expression, but without an eventual `!important` indicator!
        Returns:
        The CSS expression as a parsable String. Never null.
      • setExpression

        @Nonnull
        public final CSSDeclaration setExpression​(@Nonnull
                                                  CSSExpression aExpression)
        Set the expression (= value) of this declaration.
        Parameters:
        aExpression - The value of the property. May not be null.
        Returns:
        this
        Since:
        3.7.4
      • isImportant

        public final boolean isImportant()
        Returns:
        true if this declaration is important ( !important) or false if not.
      • setImportant

        @Nonnull
        public final CSSDeclaration setImportant​(boolean bIsImportant)
        Set the important flag of this value.
        Parameters:
        bIsImportant - true to mark it important, false to remove it.
        Returns:
        this
        Since:
        3.7.4
      • getAsCSSString

        @Nonnull
        @Nonempty
        public String getAsCSSString​(@Nonnull
                                     ICSSWriterSettings aSettings,
                                     @Nonnegative
                                     int nIndentLevel)
        Description copied from interface: ICSSWriteable
        Get the contents of this object as a serialized CSS string for writing to an output.
        Specified by:
        getAsCSSString in interface ICSSWriteable
        Parameters:
        aSettings - The settings to be used to format the output. May not be null.
        nIndentLevel - The current indentation level
        Returns:
        The content of this object as CSS string. Never null.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object