From 0aab56a0447e62d746abee5749d88668c716470e Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Sun, 31 May 2015 17:18:28 +0100 Subject: [PATCH] Code tidy up --- .../themoviedbapi/methods/AbstractMethod.java | 4 ++-- .../model/list/ListItemStatus.java | 5 ++--- .../model/person/PersonCreditList.java | 5 ++--- .../model/person/PersonInfo.java | 4 ++-- .../themoviedbapi/tools/TmdbParameters.java | 21 +++++++++---------- .../com/omertron/themoviedbapi/TestSuite.java | 8 +++++++ 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java index ae33a42a2..7e4f4dcd3 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java @@ -67,7 +67,7 @@ public class AbstractMethod { protected final HttpTools httpTools; // Jackson JSON configuration protected static final ObjectMapper MAPPER = new ObjectMapper(); - private static final Map TYPE_REFS = new HashMap(); + private static final Map TYPE_REFS = new HashMap<>(); static { TYPE_REFS.put(MovieBasic.class, new TypeReference>() { @@ -186,7 +186,7 @@ public class AbstractMethod { try { WrapperChanges wrapper = MAPPER.readValue(webpage, WrapperChanges.class); - ResultList results = new ResultList(wrapper.getChangedItems()); + ResultList results = new ResultList<>(wrapper.getChangedItems()); wrapper.setResultProperties(results); return results; } catch (IOException ex) { diff --git a/src/main/java/com/omertron/themoviedbapi/model/list/ListItemStatus.java b/src/main/java/com/omertron/themoviedbapi/model/list/ListItemStatus.java index 108da1ee3..e29c7c731 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/list/ListItemStatus.java +++ b/src/main/java/com/omertron/themoviedbapi/model/list/ListItemStatus.java @@ -21,14 +21,13 @@ package com.omertron.themoviedbapi.model.list; import com.omertron.themoviedbapi.model.AbstractJsonMapping; import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; /** * @author Holger Brandl */ -public class ListItemStatus extends AbstractJsonMapping implements Serializable { +public class ListItemStatus extends AbstractJsonMapping { - private static final long serialVersionUID = 100L; + private static final long serialVersionUID = 101L; @JsonProperty("id") private String id; diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/PersonCreditList.java b/src/main/java/com/omertron/themoviedbapi/model/person/PersonCreditList.java index 60ebbd518..091a3f169 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/person/PersonCreditList.java +++ b/src/main/java/com/omertron/themoviedbapi/model/person/PersonCreditList.java @@ -24,16 +24,15 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.omertron.themoviedbapi.interfaces.Identification; import com.omertron.themoviedbapi.model.AbstractJsonMapping; -import java.io.Serializable; import java.util.List; /** * @author stuart.boston * @param */ -public class PersonCreditList extends AbstractJsonMapping implements Serializable, Identification { +public class PersonCreditList extends AbstractJsonMapping implements Identification { - private static final long serialVersionUID = 100L; + private static final long serialVersionUID = 101L; @JsonProperty("id") private int id; diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java b/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java index 59f07bc31..4b9eec4a9 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java @@ -69,9 +69,9 @@ public class PersonInfo extends PersonBasic implements Serializable, AppendToRes // TODO: Add COMBINED_CREDITS private ExternalID externalIDs = new ExternalID(); private List images = Collections.emptyList(); - private PersonCreditList movieCredits = new PersonCreditList(); private List taggedImages = Collections.emptyList(); - private PersonCreditList tvCredits = new PersonCreditList(); + private PersonCreditList movieCredits = new PersonCreditList<>(); + private PersonCreditList tvCredits = new PersonCreditList<>(); // public boolean isAdult() { diff --git a/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java b/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java index efedeebbf..040bd836f 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java @@ -33,7 +33,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; */ public class TmdbParameters { - private final Map parameters = new EnumMap(Param.class); + private final Map parameters = new EnumMap<>(Param.class); /** * Construct an empty set of parameters @@ -51,7 +51,7 @@ public class TmdbParameters { } /** - * Add a parameter to the collection + * Add an array parameter to the collection * * @param key Parameter to add * @param value The array value to use (will be converted into a comma separated list) @@ -165,17 +165,16 @@ public class TmdbParameters { */ public String toList(final String[] appendToResponse) { StringBuilder sb = new StringBuilder(); - if (appendToResponse.length > 0) { - boolean first = Boolean.TRUE; - for (String append : appendToResponse) { - if (first) { - first = Boolean.FALSE; - } else { - sb.append(","); - } - sb.append(append); + boolean first = Boolean.TRUE; + for (String append : appendToResponse) { + if (first) { + first = Boolean.FALSE; + } else { + sb.append(","); } + sb.append(append); } + return sb.toString(); } diff --git a/src/test/java/com/omertron/themoviedbapi/TestSuite.java b/src/test/java/com/omertron/themoviedbapi/TestSuite.java index 80fcfbdc2..48475065e 100644 --- a/src/test/java/com/omertron/themoviedbapi/TestSuite.java +++ b/src/test/java/com/omertron/themoviedbapi/TestSuite.java @@ -183,6 +183,14 @@ public class TestSuite { assertTrue(message + " ID " + id + " not found in list", found); } + /** + * Test the AppendToResponse method + * + * @param + * @param test + * @param methodClass + * @param skip Any methods to skip + */ public static void testATR(AppendToResponse test, Class methodClass, T skip) { for (T method : methodClass.getEnumConstants()) { if (skip != null && method != skip) {