java.lang.Object
java.lang.Record
top.offsetmonkey538.loottablemodifier.common.api.resource.util.RegexPattern
Record Components:
isRegex - if this RegexPattern is using regex or not
patternString - the pattern as a plain string
pattern - the compiled pattern

public record RegexPattern(boolean isRegex, @NotNull String patternString, @NotNull Pattern pattern) extends Record
RegexPatterns allow either matching Identifiers directly or using regex to do so.
Use literal(String) for creating literal patterns and compile(String) for creating regex patterns.
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<RegexPattern> CODEC
  • Constructor Details

    • RegexPattern

      public RegexPattern(boolean isRegex, @NotNull @NotNull String patternString, @NotNull @NotNull Pattern pattern)
      Creates an instance of a RegexPattern record class.
      Parameters:
      isRegex - the value for the isRegex record component
      patternString - the value for the patternString record component
      pattern - the value for the pattern record component
  • Method Details

    • literal

      @Contract("_->new") public static RegexPattern literal(String literal)
      Creates a literal RegexPattern from the provided string.
      Parameters:
      literal - the literal String to match
      Returns:
      a new RegexPattern matching the provided string
    • compile

      public static RegexPattern compile(String regexPattern)
      Compiles a RegexPattern from the provided regex pattern.
      Parameters:
      regexPattern - the pattern to use
      Returns:
      a new RegexPattern compiled from the provided regex pattern
      See Also:
    • matches

      public boolean matches(CharSequence input)
      Checks if the provided character sequence matches this.
      Parameters:
      input - the character sequence to check
      Returns:
      if the provided character sequence matches this
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • isRegex

      public boolean isRegex()
      Returns the value of the isRegex record component.
      Returns:
      the value of the isRegex record component
    • patternString

      @NotNull public @NotNull String patternString()
      Returns the value of the patternString record component.
      Returns:
      the value of the patternString record component
    • pattern

      @NotNull public @NotNull Pattern pattern()
      Returns the value of the pattern record component.
      Returns:
      the value of the pattern record component