@@ -15,7 +15,7 @@ import java.util.regex.Pattern
15
15
* }
16
16
* </pre>
17
17
*/
18
- class RegexBuilder {
18
+ class RegexBuilder @Deprecated( " The old syntax will be removed in version 3.0: please use the new syntax " ) constructor() {
19
19
private val stringBuilder = StringBuilder ()
20
20
private var openGroupCount = 0
21
21
private var logFunction: (s: String ) -> Unit = {}
@@ -24,10 +24,12 @@ class RegexBuilder {
24
24
/* *
25
25
* Interface to a logger attached by the client code which will receive log messages as the regex is built.
26
26
*/
27
+ @Deprecated(" Logging will be removed in version 3.0" )
27
28
interface Logger {
28
29
/* *
29
30
* Log a [message] to a debugger or logging framework
30
31
*/
32
+ @Deprecated(" Logging will be removed in version 3.0" )
31
33
fun log (message : String )
32
34
}
33
35
@@ -40,6 +42,7 @@ class RegexBuilder {
40
42
* @throws RegexBuilderException An error occurred when building the regex
41
43
*/
42
44
@Throws(RegexBuilderException ::class )
45
+ @Deprecated(" The old syntax will be removed in version 3.0: please use regex" )
43
46
fun buildRegex (vararg options : RegexOptions ): Regex =
44
47
when (openGroupCount) {
45
48
0 -> {
@@ -70,12 +73,14 @@ class RegexBuilder {
70
73
* @throws RegexBuilderException An error occurred when building the regex
71
74
*/
72
75
@Throws(RegexBuilderException ::class )
76
+ @Deprecated(" The old syntax will be removed in version 3.0: please use pattern" )
73
77
fun buildPattern (vararg options : RegexOptions ): Pattern = buildRegex(* options).toPattern()
74
78
75
79
/* *
76
80
* Attach a [logger] to this builder using this [Logger] interface. The builder will emit logging messages to it as
77
81
* the regex is built with the prefix "RegexBuilder".
78
82
*/
83
+ @Deprecated(" Logging will be removed in version 3.0" )
79
84
fun addLogger (logger : Logger ): RegexBuilder {
80
85
return addLogger{
81
86
logger.log(it)
@@ -86,6 +91,7 @@ class RegexBuilder {
86
91
* Attach a [logger] to this builder using this [Logger] interface. The builder will emit logging messages to it as
87
92
* the regex is built with the provided [prefix].
88
93
*/
94
+ @Deprecated(" Logging will be removed in version 3.0" )
89
95
fun addLogger (prefix : String , logger : Logger ): RegexBuilder {
90
96
return addLogger(prefix) {
91
97
logger.log(it)
@@ -96,6 +102,7 @@ class RegexBuilder {
96
102
* Attach a logger to this builder using the provided log function. The builder will emit logging messages to it
97
103
* as the regex is built with the prefix "RegexBuilder".
98
104
*/
105
+ @Deprecated(" Logging will be removed in version 3.0" )
99
106
fun addLogger (logFunction : (s: String ) -> Unit ): RegexBuilder {
100
107
this .logFunction = logFunction
101
108
return this
@@ -105,6 +112,7 @@ class RegexBuilder {
105
112
* Attach a logger to this builder using the provided log function. The builder will emit logging messages to it
106
113
* as the regex is built with the provided [prefix].
107
114
*/
115
+ @Deprecated(" Logging will be removed in version 3.0" )
108
116
fun addLogger (prefix : String , logFunction : (s: String ) -> Unit ): RegexBuilder {
109
117
this .logFunction = logFunction
110
118
this .prefix = prefix
@@ -467,6 +475,7 @@ class RegexBuilder {
467
475
*
468
476
* @return The current [RegexBuilder] object, for method chaining
469
477
*/
478
+ @Deprecated(" The old syntax will be removed in version 3.0: please use group" )
470
479
fun startGroup (): RegexBuilder {
471
480
openGroupCount++
472
481
return addPart(" startGroup()" , " (" )
@@ -483,6 +492,7 @@ class RegexBuilder {
483
492
*
484
493
* @return The current [RegexBuilder] object, for method chaining
485
494
*/
495
+ @Deprecated(" The old syntax will be removed in version 3.0: please use nonCapturingGroup" )
486
496
fun startNonCapturingGroup (): RegexBuilder {
487
497
openGroupCount++
488
498
return addPart(" startNonCapturingGroup()" , " (?:" )
@@ -501,6 +511,7 @@ class RegexBuilder {
501
511
* @param name Name used to identify the group
502
512
* @return The current [RegexBuilder] object, for method chaining
503
513
*/
514
+ @Deprecated(" The old syntax will be removed in version 3.0: please use namedGroup" )
504
515
fun startNamedGroup (name : String ): RegexBuilder {
505
516
openGroupCount++
506
517
return addPart(" startNamedGroup(\" $name \" )" , " (?<$name >" )
@@ -515,6 +526,7 @@ class RegexBuilder {
515
526
* @throws RegexBuilderException A group has not been started
516
527
*/
517
528
@Throws(RegexBuilderException ::class )
529
+ @Deprecated(" The old syntax will be removed in version 3.0: please use new group syntax" )
518
530
fun endGroup (quantifier : RegexQuantifier ? = null): RegexBuilder {
519
531
if (openGroupCount == 0 ) {
520
532
throw RegexBuilderException (
0 commit comments