@@ -30,8 +30,8 @@ class TestGithub145 {
30
30
}
31
31
32
32
@Test
33
- fun testPersonGood2 () {
34
- class PersonGood1 (
33
+ fun testPerson2 () {
34
+ class Person2 (
35
35
@JsonProperty(" preName" ) val preName : String ,
36
36
@JsonProperty(" lastName" ) val lastName : String
37
37
) {
@@ -42,29 +42,27 @@ class TestGithub145 {
42
42
)
43
43
}
44
44
45
- val personGood1String = objectMapper.readValue<PersonGood1 >(""" "TestPreName,TestLastname"""" )
46
- val personGood1Json =
47
- objectMapper.readValue<PersonGood1 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
45
+ val person1String = objectMapper.readValue<Person2 >(""" "TestPreName,TestLastname"""" )
46
+ val person1Json = objectMapper.readValue<Person2 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
48
47
}
49
48
50
49
@Test
51
- fun testPersonGood3 () {
52
- class PersonGood2 (val preName : String , val lastName : String ) {
50
+ fun testPerson3 () {
51
+ class Person3 (val preName : String , val lastName : String ) {
53
52
@JsonCreator
54
53
constructor (preNameAndLastName: String ) : this (
55
54
preNameAndLastName.substringBefore(" ," ),
56
55
preNameAndLastName.substringAfter(" ," )
57
56
)
58
57
}
59
58
60
- val personGood2String = objectMapper.readValue<PersonGood2 >(""" "TestPreName,TestLastname"""" )
61
- val personGood2Json =
62
- objectMapper.readValue<PersonGood2 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
59
+ val person2String = objectMapper.readValue<Person3 >(""" "TestPreName,TestLastname"""" )
60
+ val person2Json = objectMapper.readValue<Person3 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
63
61
}
64
62
65
63
@Test
66
- fun testPersonGood4 () {
67
- class PersonGood4 (preNameAndLastName : String ) {
64
+ fun testPerson4 () {
65
+ class Person4 (preNameAndLastName : String ) {
68
66
val preName: String
69
67
val lastName: String
70
68
@@ -74,13 +72,13 @@ class TestGithub145 {
74
72
}
75
73
}
76
74
77
- val personGood4String = objectMapper.readValue<PersonGood4 >(""" "TestPreName,TestLastname"""" )
75
+ val person4String = objectMapper.readValue<Person4 >(""" "TestPreName,TestLastname"""" )
78
76
// person4 does not have parameter bound constructor, only string
79
77
}
80
78
81
79
@Test
82
- fun testPersonGood5 () {
83
- class PersonGood5 @JsonCreator constructor(
80
+ fun testPerson5 () {
81
+ class Person5 @JsonCreator constructor(
84
82
@JsonProperty(" preName" ) val preName : String ,
85
83
@JsonProperty(" lastName" ) val lastName : String
86
84
) {
@@ -89,13 +87,12 @@ class TestGithub145 {
89
87
this (preNameAndLastName.substringBefore(" ," ), preNameAndLastName.substringAfter(" ," ))
90
88
}
91
89
92
- val personGood5String = objectMapper.readValue<PersonGood5 >(""" "TestPreName,TestLastname"""" )
93
- val personGood5Json =
94
- objectMapper.readValue<PersonGood5 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
90
+ val person5String = objectMapper.readValue<Person5 >(""" "TestPreName,TestLastname"""" )
91
+ val person5Json = objectMapper.readValue<Person5 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
95
92
}
96
93
97
94
// Cannot have companion object in class declared within function
98
- class PersonGood6 private constructor(val preName : String , val lastName : String ) {
95
+ class Person6 private constructor(val preName : String , val lastName : String ) {
99
96
private constructor (preNameAndLastName: String ) : this (
100
97
preNameAndLastName.substringBefore(" ," ),
101
98
preNameAndLastName.substringAfter(" ," )
@@ -104,27 +101,26 @@ class TestGithub145 {
104
101
companion object {
105
102
@JsonCreator
106
103
@JvmStatic
107
- fun createFromJson (preNameAndLastName : String ): PersonGood6 {
108
- return PersonGood6 (preNameAndLastName)
104
+ fun createFromJson (preNameAndLastName : String ): Person6 {
105
+ return Person6 (preNameAndLastName)
109
106
}
110
107
111
108
@JsonCreator
112
109
@JvmStatic
113
- fun createFromData (preName : String , lastName : String ): PersonGood6 {
114
- return PersonGood6 (preName, lastName)
110
+ fun createFromData (preName : String , lastName : String ): Person6 {
111
+ return Person6 (preName, lastName)
115
112
}
116
113
}
117
114
}
118
115
119
116
@Test
120
- fun testPersonGood6 () {
121
- val personGood6String = objectMapper.readValue<PersonGood6 >(""" "TestPreName,TestLastname"""" )
122
- val personGood6Json =
123
- objectMapper.readValue<PersonGood6 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
117
+ fun testPerson6 () {
118
+ val person6String = objectMapper.readValue<Person6 >(""" "TestPreName,TestLastname"""" )
119
+ val person6Json = objectMapper.readValue<Person6 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
124
120
}
125
121
126
122
// Cannot have companion object in class declared within function
127
- class PersonGood7 constructor(val preName : String , val lastName : String ) {
123
+ class Person7 constructor(val preName : String , val lastName : String ) {
128
124
private constructor (preNameAndLastName: String ) : this (
129
125
preNameAndLastName.substringBefore(" ," ),
130
126
preNameAndLastName.substringAfter(" ," )
@@ -133,16 +129,15 @@ class TestGithub145 {
133
129
companion object {
134
130
@JsonCreator
135
131
@JvmStatic
136
- fun createFromJson (preNameAndLastName : String ): PersonGood7 {
137
- return PersonGood7 (preNameAndLastName)
132
+ fun createFromJson (preNameAndLastName : String ): Person7 {
133
+ return Person7 (preNameAndLastName)
138
134
}
139
135
}
140
136
}
141
137
142
138
@Test
143
- fun testPersonGood7 () {
144
- val personGood7String = objectMapper.readValue<PersonGood7 >(""" "TestPreName,TestLastname"""" )
145
- val personGood7Json =
146
- objectMapper.readValue<PersonGood7 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
139
+ fun testPerson7 () {
140
+ val person7String = objectMapper.readValue<Person7 >(""" "TestPreName,TestLastname"""" )
141
+ val person7Json = objectMapper.readValue<Person7 >(""" {"preName":"TestPreName","lastName":"TestLastname"}""" )
147
142
}
148
143
}
0 commit comments