44
55public final class Pronoun {
66
7- private final String subjective ;
8- private final String objective ;
9- private final String possessive ;
10- private final String possessiveAdjective ;
11- private final String reflexive ;
7+ private String subjective = "" ;
8+ private String objective = "" ;
9+ private String possessive = "" ;
10+ private String possessiveAdjective = "" ;
11+ private String reflexive = "" ;
1212
1313 public Pronoun (String subjective , String objective , String possessive , String possessiveAdjective ,
1414 String reflexive ) {
@@ -30,15 +30,18 @@ public String toString() {
3030 }
3131
3232 public static String serialize (@ NotNull Pronoun pronoun ) {
33- return String .format ("%s///%s///%s///%s///%s" ,
34- pronoun .subjective , pronoun .objective , pronoun .possessive ,
35- pronoun .possessiveAdjective , pronoun .reflexive );
33+ return String .join ("///" ,
34+ pronoun .subjective .isEmpty () ? " " : pronoun .subjective ,
35+ pronoun .objective .isEmpty () ? " " : pronoun .objective ,
36+ pronoun .possessive .isEmpty () ? " " : pronoun .possessive ,
37+ pronoun .possessiveAdjective .isEmpty () ? " " : pronoun .possessiveAdjective ,
38+ pronoun .reflexive .isEmpty () ? " " : pronoun .reflexive );
3639 }
3740
3841 public static Pronoun deserialize (@ NotNull String string ) {
39- String [] arr = string .split ("///" );
42+ String [] arr = string .split ("///" , - 1 ); // Ensure split keeps empty fields
4043 if (arr .length != 5 ) return null ;
41- return new Pronoun (arr [0 ], arr [1 ], arr [2 ], arr [3 ], arr [4 ]);
44+ return new Pronoun (arr [0 ]. trim () , arr [1 ]. trim () , arr [2 ]. trim () , arr [3 ]. trim () , arr [4 ]. trim () );
4245 }
4346
4447 public String getObjective () {
0 commit comments