Skip to content

Commit f161bc7

Browse files
committed
Implement StringToRegexConverter in Java
This commit implements StringToRegexConverter in Java in order to avoid circular dependencies between Java and Kotlin codes that can break IDE support, and for consistency with the rest of the codebase. See spring-projectsgh-24311
1 parent 471e4d2 commit f161bc7

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2002-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.core.convert.support;
18+
19+
import kotlin.text.Regex;
20+
21+
import org.springframework.core.convert.converter.Converter;
22+
23+
/**
24+
* Converts from a String to a {@link Regex}.
25+
*
26+
* @author Stephane Nicoll
27+
* @author Sebastien Deleuze
28+
*/
29+
class StringToRegexConverter implements Converter<String, Regex> {
30+
31+
@Override
32+
public Regex convert(String source) {
33+
if (source.isEmpty()) {
34+
return null;
35+
}
36+
return new Regex(source);
37+
}
38+
39+
}

spring-core/src/main/kotlin/org/springframework/core/convert/support/StringToRegexConverter.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)