-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathZoo.java
More file actions
33 lines (25 loc) · 841 Bytes
/
Zoo.java
File metadata and controls
33 lines (25 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package jackpoly;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
@JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, include = As.PROPERTY, property = "@class")
class Zoo {
public final String name;
public String city;
public List<Animal> animals;
@JsonCreator
public Zoo(@JsonProperty("name") String name, @JsonProperty("city") String city) {
this.name = name;
this.city = city;
}
public void setAnimals(List<Animal> animals) {
this.animals = animals;
}
@Override
public String toString() {
return "Zoo [name=" + name + ", city=" + city + ", animals=" + animals + "]";
}
}