Package groovy.util.regex
Record Class BalancedGroup.MatchOptions
java.lang.Object
java.lang.Record
groovy.util.regex.BalancedGroup.MatchOptions
- Record Components:
ignoreRegex- regex for spans to skip while scanning (e.g. string literals or escape sequences);nullor blank means ignore nothing. This is the practical counterpart to writing “neither open nor close” character classes in a hand-built .NET balancing pattern.includeEdges-trueto keep opening/closing delimiters inBalancedGroup.getMatchedString();falseto strip them (like .NET's balancing capture of the interval between the subtracted open capture and the close match)
- Enclosing class:
- BalancedGroup
public static record BalancedGroup.MatchOptions(String ignoreRegex, boolean includeEdges)
extends Record
Options controlling balanced-group matching.
Instances are immutable; use the with* methods to derive variants.
- Since:
- 6.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionMatchOptions(String ignoreRegex, boolean includeEdges) Creates an instance of aMatchOptionsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic BalancedGroup.MatchOptionsdefaults()Default options: nothing ignored, delimiters included.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theignoreRegexrecord component.booleanReturns the value of theincludeEdgesrecord component.final StringtoString()Returns a string representation of this record class.withIgnoreRegex(String ignoreRegex) Returns a copy with the given ignore regex.withIncludeEdges(boolean includeEdges) Returns a copy with the given edge-inclusion policy.
-
Constructor Details
-
MatchOptions
Creates an instance of aMatchOptionsrecord class.- Parameters:
ignoreRegex- the value for theignoreRegexrecord componentincludeEdges- the value for theincludeEdgesrecord component
-
-
Method Details
-
defaults
Default options: nothing ignored, delimiters included.- Returns:
- the default options
-
withIgnoreRegex
Returns a copy with the given ignore regex.- Parameters:
ignoreRegex- regex of content to skip, ornull/blank for none- Returns:
- a new options instance
-
withIncludeEdges
Returns a copy with the given edge-inclusion policy.- Parameters:
includeEdges- whether matched text keeps opening/closing delimiters- Returns:
- a new options instance
-
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 '=='. -
ignoreRegex
Returns the value of theignoreRegexrecord component.- Returns:
- the value of the
ignoreRegexrecord component
-
includeEdges
public boolean includeEdges()Returns the value of theincludeEdgesrecord component.- Returns:
- the value of the
includeEdgesrecord component
-