We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d578050 commit 10c7454Copy full SHA for 10c7454
src/main/java/hello/typeconverter/converter/StringToIpPortConverter.java
@@ -0,0 +1,20 @@
1
+package hello.typeconverter.converter;
2
+
3
+import hello.typeconverter.type.IpPort;
4
+import lombok.extern.slf4j.Slf4j;
5
+import org.springframework.core.convert.converter.Converter;
6
7
+@Slf4j
8
+public class StringToIpPortConverter implements Converter<String, IpPort> {
9
10
+ @Override
11
+ public IpPort convert(String source) {
12
+ log.info("convert source={}", source);
13
+ // 127.0.0.1:8080 -> IpPort 객체
14
+ String[] split = source.split(":");
15
+ String ip = split[0];
16
+ int port = Integer.parseInt(split[1]);
17
+ return new IpPort(ip, port);
18
+ }
19
20
+}
0 commit comments