Record Class FindFormat

java.lang.Object
java.lang.Record
io.keikai.axyra.sheets.FindFormat
Record Components:
fillColor - the fill foreground (pattern) color to match, or null for any
fontColor - the font color to match, or null for any
bold - the bold flag to match, or null for any
italic - the italic flag to match, or null for any
numberFormat - the number format code to match, or null for any

public record FindFormat(Color fillColor, Color fontColor, Boolean bold, Boolean italic, String numberFormat) extends Record
A style predicate for format-restricted find/replace (Excel's Find & Replace → Format... filter) — see Sheet.find(String, FindFormat) and Sheet.replaceAll(String, String, FindFormat).

Matching semantics. Only the fields that are set (non-null) participate; every set field must equal the corresponding component of the cell's resolved style. A cell without an explicit style resolves to the workbook default style, so e.g. withBold(false) matches unstyled cells. Colors compare by RGB value only and must be RGB colors — a cell whose color is a theme/indexed/automatic reference never matches a color field. numberFormat compares the resolved number format code (an unformatted cell resolves to "General").

Build with the empty of() filter and the withX copies: FindFormat.of().withBold(true).withFillColor(Color.YELLOW).

  • Constructor Details

    • FindFormat

      public FindFormat(Color fillColor, Color fontColor, Boolean bold, Boolean italic, String numberFormat)
      Creates an instance of a FindFormat record class.
      Parameters:
      fillColor - the value for the fillColor record component
      fontColor - the value for the fontColor record component
      bold - the value for the bold record component
      italic - the value for the italic record component
      numberFormat - the value for the numberFormat record component
  • Method Details

    • of

      public static FindFormat of()
      Returns the empty filter: no criteria, so a cell's style does not restrict the match. Add criteria with the withX methods.
    • withFillColor

      public FindFormat withFillColor(Color c)
      Returns a copy matching cells whose fill foreground (pattern) color equals c. c must be an RGB color; a theme, indexed or automatic color is accepted here but makes Sheet.find(String, FindFormat) and Sheet.replaceAll(String, String, FindFormat) throw IllegalArgumentException. null removes this criterion.
    • withFontColor

      public FindFormat withFontColor(Color c)
      Returns a copy matching cells whose font color equals c. c must be an RGB color; a theme, indexed or automatic color is accepted here but makes Sheet.find(String, FindFormat) and Sheet.replaceAll(String, String, FindFormat) throw IllegalArgumentException. null removes this criterion.
    • withBold

      public FindFormat withBold(boolean b)
      Returns a copy matching cells whose resolved font bold flag equals b.
    • withItalic

      public FindFormat withItalic(boolean i)
      Returns a copy matching cells whose resolved font italic flag equals i.
    • withNumberFormat

      public FindFormat withNumberFormat(String code)
      Returns a copy matching cells whose resolved number format code equals code, e.g. "0.00"; unformatted cells resolve to "General". null removes this criterion.
    • isEmpty

      public boolean isEmpty()
      Returns whether no criterion is set.
    • 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 Objects::equals(Object,Object).
      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.
    • fillColor

      public Color fillColor()
      Returns the value of the fillColor record component.
      Returns:
      the value of the fillColor record component
    • fontColor

      public Color fontColor()
      Returns the value of the fontColor record component.
      Returns:
      the value of the fontColor record component
    • bold

      public Boolean bold()
      Returns the value of the bold record component.
      Returns:
      the value of the bold record component
    • italic

      public Boolean italic()
      Returns the value of the italic record component.
      Returns:
      the value of the italic record component
    • numberFormat

      public String numberFormat()
      Returns the value of the numberFormat record component.
      Returns:
      the value of the numberFormat record component