Record Class CssBoxModel

java.lang.Object
java.lang.Record
dev.jcputney.mjml.util.CssBoxModel
Record Components:
paddingTop - the top padding in pixels
paddingRight - the right padding in pixels
paddingBottom - the bottom padding in pixels
paddingLeft - the left padding in pixels
borderLeftWidth - the left border width in pixels
borderRightWidth - the right border width in pixels

public record CssBoxModel(double paddingTop, double paddingRight, double paddingBottom, double paddingLeft, double borderLeftWidth, double borderRightWidth) extends Record
Calculates padding and border box dimensions from CSS shorthand values.
  • Constructor Details

    • CssBoxModel

      public CssBoxModel(double paddingTop, double paddingRight, double paddingBottom, double paddingLeft, double borderLeftWidth, double borderRightWidth)
      Creates an instance of a CssBoxModel record class.
      Parameters:
      paddingTop - the value for the paddingTop record component
      paddingRight - the value for the paddingRight record component
      paddingBottom - the value for the paddingBottom record component
      paddingLeft - the value for the paddingLeft record component
      borderLeftWidth - the value for the borderLeftWidth record component
      borderRightWidth - the value for the borderRightWidth record component
  • Method Details

    • fromAttributes

      public static CssBoxModel fromAttributes(String padding, String border, String borderLeft, String borderRight)
      Creates a CssBoxModel from padding and border attribute strings.
      Parameters:
      padding - the CSS padding shorthand string (e.g., "10px 20px")
      border - the CSS border shorthand string (e.g., "1px solid #000")
      borderLeft - the CSS left border shorthand string
      borderRight - the CSS right border shorthand string
      Returns:
      a new CssBoxModel with parsed padding and border values
    • horizontalSpacing

      public double horizontalSpacing()
      Total horizontal spacing (left + right padding + borders).
      Returns:
      the sum of left padding, right padding, left border width, and right border width
    • verticalSpacing

      public double verticalSpacing()
      Total vertical spacing (top + bottom padding).
      Returns:
      the sum of top and bottom padding
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • paddingTop

      public double paddingTop()
      Returns the value of the paddingTop record component.
      Returns:
      the value of the paddingTop record component
    • paddingRight

      public double paddingRight()
      Returns the value of the paddingRight record component.
      Returns:
      the value of the paddingRight record component
    • paddingBottom

      public double paddingBottom()
      Returns the value of the paddingBottom record component.
      Returns:
      the value of the paddingBottom record component
    • paddingLeft

      public double paddingLeft()
      Returns the value of the paddingLeft record component.
      Returns:
      the value of the paddingLeft record component
    • borderLeftWidth

      public double borderLeftWidth()
      Returns the value of the borderLeftWidth record component.
      Returns:
      the value of the borderLeftWidth record component
    • borderRightWidth

      public double borderRightWidth()
      Returns the value of the borderRightWidth record component.
      Returns:
      the value of the borderRightWidth record component