1
1
package de .votesapp .client ;
2
2
3
3
import javax .annotation .Nullable ;
4
+ import javax .validation .constraints .NotNull ;
4
5
5
6
import lombok .AllArgsConstructor ;
6
7
import lombok .Data ;
7
8
import lombok .NoArgsConstructor ;
8
9
10
+ import org .apache .commons .lang3 .StringUtils ;
11
+
9
12
import com .fasterxml .jackson .annotation .JsonCreator ;
10
13
import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
11
14
import com .fasterxml .jackson .annotation .JsonProperty ;
22
25
@ NoArgsConstructor
23
26
public class GroupMessage {
24
27
25
- public static GroupMessage of (final String groupId , final String text ) {
28
+ public static GroupMessage of (final String groupId , @ NotNull final String text ) {
26
29
return new GroupMessage (null , escapeDot (groupId ), null , null , text );
27
30
}
28
31
@@ -33,9 +36,9 @@ public static GroupMessage of( //
33
36
@ JsonProperty ("_from" ) final String groupId , //
34
37
@ JsonProperty ("participant" ) final String senderPhone , //
35
38
@ JsonProperty (value = "notify" , required = false ) final String senderName , //
36
- @ JsonProperty ("body" ) final String text ) {
39
+ @ JsonProperty (value = "body" , required = false ) final String text ) {
37
40
38
- return new GroupMessage (escapeDot (id ), escapeDot (groupId ), escapeDot (senderPhone ), senderName , text );
41
+ return new GroupMessage (escapeDot (id ), escapeDot (groupId ), escapeDot (senderPhone ), senderName , text == null ? "" : text );
39
42
}
40
43
41
44
private static String escapeDot (final String txt ) {
@@ -50,7 +53,7 @@ private static String escapeDot(final String txt) {
50
53
// return mappingMongoConverter;
51
54
// }
52
55
// But then we need to have one. Now it's autoconfigured
53
- return txt . replaceAll ( " \\ ." , "_" );
56
+ return StringUtils . replace ( txt , " ." , "_" );
54
57
}
55
58
56
59
/**
0 commit comments