Refactor Gson examples
This commit is contained in:
parent
a0b086c4c3
commit
fa6f482f2a
|
@ -16,6 +16,10 @@ public class ActorGson {
|
|||
this.filmography = filmography;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActorGson [imdbId=" + imdbId + ", dateOfBirth=" + dateOfBirth + ", filmography=" + filmography + "]";
|
||||
}
|
||||
|
||||
public String getImdbId() {
|
||||
return imdbId;
|
||||
|
@ -41,8 +45,5 @@ public class ActorGson {
|
|||
this.filmography = filmography;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActorGson [imdbId=" + imdbId + ", dateOfBirth=" + dateOfBirth + ", filmography=" + filmography + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -4,11 +4,6 @@ import java.util.List;
|
|||
|
||||
public class Movie {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Movie [imdbId=" + imdbId + ", director=" + director + ", actors=" + actors + "]";
|
||||
}
|
||||
|
||||
private String imdbId;
|
||||
private String director;
|
||||
private List<ActorGson> actors;
|
||||
|
@ -20,6 +15,11 @@ public class Movie {
|
|||
this.actors = actors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Movie [imdbId=" + imdbId + ", director=" + director + ", actors=" + actors + "]";
|
||||
}
|
||||
|
||||
public String getImdbID() {
|
||||
return imdbId;
|
||||
}
|
||||
|
@ -43,4 +43,6 @@ public class Movie {
|
|||
public void setActors(List<ActorGson> actors) {
|
||||
this.actors = actors;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
package org.baeldung.gson.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MovieWithNullValue {
|
||||
|
||||
@Expose
|
||||
private String imdbId;
|
||||
private String director;
|
||||
|
||||
@Expose
|
||||
private List<ActorGson> actors;
|
||||
|
||||
|
|
|
@ -1,24 +1,12 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
|
||||
import com.google.gson.*;
|
||||
import org.baeldung.gson.entities.ActorGson;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.baeldung.gson.entities.ActorGson;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
public class ActorGsonDeserializer implements JsonDeserializer<ActorGson> {
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.baeldung.gson.entities.ActorGson;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import org.baeldung.gson.entities.ActorGson;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ActorGsonSerializer implements JsonSerializer<ActorGson> {
|
||||
|
||||
|
|
Loading…
Reference in New Issue