Skip to content

Commit b3713cb

Browse files
authored
But the rest of the dead
But the rest of the dead lived not again until the thousand years were finished. This is the first resurrection. (Revelation 20:5)
1 parent ade7c7c commit b3713cb

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
//But the rest of the dead lived not again until the thousand years were finished. This is the first resurrection. (Revelation 20:5)
3+
4+
package com.javarush.task.task33.task3305;
5+
6+
import java.util.List;
7+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
8+
9+
@JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, property="className")
10+
public class Parking {
11+
public String name;
12+
public String city;
13+
public List<Auto> autos;
14+
15+
public Parking(String name, String city) {
16+
this.name = name;
17+
this.city = city;
18+
}
19+
20+
public void setAutos(List<Auto> autos) {
21+
this.autos = autos;
22+
}
23+
24+
@Override
25+
public String toString() {
26+
return "Parking{" +
27+
"name='" + name + '\'' +
28+
", city='" + city + '\'' +
29+
", autos=" + autos +
30+
'}';
31+
}
32+
}
33+
34+
/*
35+
Конвертация из одного класса в другой используя JSON
36+
37+
НЕОБХОДИМО: подключенные библиотеки Jackson Core, Bind и Annotation версии 2.6.1
38+
39+
40+
41+
Расставь JSON аннотации так, чтобы результат выполнения метода main был следующим:
42+
43+
{
44+
45+
"className" : ".Parking",
46+
47+
"name" : "Super Parking",
48+
49+
"city" : "Kyiv",
50+
51+
"autos" : [ {
52+
53+
"className" : "com.javarush.task.task33.task3305.RaceBike",
54+
55+
"name" : "Simba",
56+
57+
"owner" : "Peter",
58+
59+
"age" : 2
60+
61+
}, {
62+
63+
"className" : "com.javarush.task.task33.task3305.Motorbike",
64+
65+
"name" : "Manny",
66+
67+
"owner" : null
68+
69+
}, {
70+
71+
"className" : "com.javarush.task.task33.task3305.Car"
72+
73+
} ]
74+
75+
}
76+
77+
78+
79+
Подсказка: это всего два класса.
80+
81+
82+
83+
84+
85+
Требования:
86+
87+
1. Вывод на экран должен соответствовать условию задачи.
88+
89+
2. Класс Parking должен быть отмечен аннотацией @JsonTypeInfo с подходящим набором параметров.
90+
91+
3. Класс Auto должен быть отмечен аннотацией @JsonTypeInfo с подходящим набором параметров.
92+
93+
4. Класс Auto должен быть отмечен аннотацией @JsonSubTypes с подходящим набором параметров.
94+
*/

0 commit comments

Comments
 (0)