Record Class StandardPlaceholder

java.lang.Object
java.lang.Record
pro.verron.officestamper.experimental.StandardPlaceholder
Record Components:
matcher - the matcher to use for determining if the expression matches.
expression - the expression string.
All Implemented Interfaces:
Placeholder

public record StandardPlaceholder(Matcher matcher, String expression) extends Record implements Placeholder
The StandardPlaceholder class represents a placeholder with a specific matching condition and associated expression. It uses a Matcher to determine if the placeholder expression matches a given prefix and suffix, and to extract the inner content of the placeholder.
  • Constructor Details

    • StandardPlaceholder

      public StandardPlaceholder(Matcher matcher, String expression)
      Creates an instance of a StandardPlaceholder record class.
      Parameters:
      matcher - the value for the matcher record component
      expression - the value for the expression record component
  • Method Details

    • content

      public String content()
      Retrieves the processed content of the placeholder. If the expression matches the criteria defined by the Matcher, the prefix and suffix are stripped from the expression. Otherwise, the original expression is returned.
      Specified by:
      content in interface Placeholder
      Returns:
      the inner content of the expression if the match criteria are met; otherwise, the complete original expression.
    • toString

      public String toString()
      Returns a string representation of this object. The representation is enclosed in square brackets and includes the expression.
      Specified by:
      toString in class Record
      Returns:
      a string in the format "[expression]" where "expression" is the value of the expression field.
    • 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.
    • matcher

      public Matcher matcher()
      Returns the value of the matcher record component.
      Returns:
      the value of the matcher record component
    • expression

      public String expression()
      Returns the value of the expression record component.
      Specified by:
      expression in interface Placeholder
      Returns:
      the value of the expression record component