11package de .votesapp .client ;
22
33import javax .annotation .Nullable ;
4+ import javax .validation .constraints .NotNull ;
45
56import lombok .AllArgsConstructor ;
67import lombok .Data ;
78import lombok .NoArgsConstructor ;
89
10+ import org .apache .commons .lang3 .StringUtils ;
11+
912import com .fasterxml .jackson .annotation .JsonCreator ;
1013import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
1114import com .fasterxml .jackson .annotation .JsonProperty ;
2225@ NoArgsConstructor
2326public class GroupMessage {
2427
25- public static GroupMessage of (final String groupId , final String text ) {
28+ public static GroupMessage of (final String groupId , @ NotNull final String text ) {
2629 return new GroupMessage (null , escapeDot (groupId ), null , null , text );
2730 }
2831
@@ -33,9 +36,9 @@ public static GroupMessage of( //
3336 @ JsonProperty ("_from" ) final String groupId , //
3437 @ JsonProperty ("participant" ) final String senderPhone , //
3538 @ JsonProperty (value = "notify" , required = false ) final String senderName , //
36- @ JsonProperty ("body" ) final String text ) {
39+ @ JsonProperty (value = "body" , required = false ) final String text ) {
3740
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 );
3942 }
4043
4144 private static String escapeDot (final String txt ) {
@@ -50,7 +53,7 @@ private static String escapeDot(final String txt) {
5053 // return mappingMongoConverter;
5154 // }
5255 // But then we need to have one. Now it's autoconfigured
53- return txt . replaceAll ( " \\ ." , "_" );
56+ return StringUtils . replace ( txt , " ." , "_" );
5457 }
5558
5659 /**
0 commit comments