Record Class RegexPattern
java.lang.Object
java.lang.Record
top.offsetmonkey538.loottablemodifier.common.api.resource.util.RegexPattern
- Record Components:
isRegex- if thisRegexPatternis using regex or notpatternString- the pattern as a plain stringpattern- 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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRegexPattern(boolean isRegex, @NotNull String patternString, @NotNull Pattern pattern) Creates an instance of aRegexPatternrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic RegexPatternCompiles aRegexPatternfrom the provided regex pattern.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisRegex()Returns the value of theisRegexrecord component.static RegexPatternCreates a literalRegexPatternfrom the provided string.booleanmatches(CharSequence input) Checks if the provided character sequence matches this.@NotNull Patternpattern()Returns the value of thepatternrecord component.@NotNull StringReturns the value of thepatternStringrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
-
-
Constructor Details
-
RegexPattern
public RegexPattern(boolean isRegex, @NotNull @NotNull String patternString, @NotNull @NotNull Pattern pattern) Creates an instance of aRegexPatternrecord class.- Parameters:
isRegex- the value for theisRegexrecord componentpatternString- the value for thepatternStringrecord componentpattern- the value for thepatternrecord component
-
-
Method Details
-
literal
Creates a literalRegexPatternfrom the provided string.- Parameters:
literal- the literal String to match- Returns:
- a new
RegexPatternmatching the provided string
-
compile
Compiles aRegexPatternfrom the provided regex pattern.- Parameters:
regexPattern- the pattern to use- Returns:
- a new
RegexPatterncompiled from the provided regex pattern - See Also:
-
matches
Checks if the provided character sequence matches this.- Parameters:
input- the character sequence to check- Returns:
- if the provided character sequence matches this
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
isRegex
public boolean isRegex()Returns the value of theisRegexrecord component.- Returns:
- the value of the
isRegexrecord component
-
patternString
Returns the value of thepatternStringrecord component.- Returns:
- the value of the
patternStringrecord component
-
pattern
Returns the value of thepatternrecord component.- Returns:
- the value of the
patternrecord component
-