Add Interfaces where appropriate
This commit is contained in:
+2
-2
@@ -17,9 +17,9 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
package com.omertron.themoviedbapi.interfaces;
|
||||
|
||||
public interface IWrapperId {
|
||||
public interface IIdentification {
|
||||
|
||||
int getId();
|
||||
|
||||
+3
-1
@@ -17,7 +17,9 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
package com.omertron.themoviedbapi.interfaces;
|
||||
|
||||
import com.omertron.themoviedbapi.wrapper.ResultDates;
|
||||
|
||||
public interface IWrapperDates {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
package com.omertron.themoviedbapi.interfaces;
|
||||
|
||||
public interface IWrapperPages {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.wrapper.IWrapperId;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
*
|
||||
* @author Stuart.Boston
|
||||
*/
|
||||
public class AbstractIdName extends AbstractJsonMapping implements IWrapperId {
|
||||
public class AbstractIdName extends AbstractJsonMapping implements IIdentification {
|
||||
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
@@ -37,6 +37,7 @@ public class AbstractIdName extends AbstractJsonMapping implements IWrapperId {
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -45,6 +46,7 @@ public class AbstractIdName extends AbstractJsonMapping implements IWrapperId {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,9 @@ package com.omertron.themoviedbapi.model.account;
|
||||
|
||||
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
|
||||
public class Account extends AbstractJsonMapping {
|
||||
public class Account extends AbstractJsonMapping implements IIdentification{
|
||||
|
||||
@JsonProperty("id")
|
||||
private int id;
|
||||
@@ -37,10 +38,12 @@ public class Account extends AbstractJsonMapping {
|
||||
@JsonProperty("iso_3166_1")
|
||||
private String country;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ public class Artwork extends AbstractJsonMapping {
|
||||
}
|
||||
|
||||
@JsonSetter("image_type")
|
||||
public void setArtworkType(String artworkType){
|
||||
this.artworkType=ArtworkType.fromString(artworkType);
|
||||
public void setArtworkType(String artworkType) {
|
||||
this.artworkType = ArtworkType.fromString(artworkType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,14 +21,14 @@ package com.omertron.themoviedbapi.model.company;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
|
||||
import com.omertron.themoviedbapi.wrapper.IWrapperId;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
|
||||
/**
|
||||
* Company information
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class Company extends AbstractJsonMapping implements IWrapperId {
|
||||
public class Company extends AbstractJsonMapping implements IIdentification {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String DEFAULT_STRING = "";
|
||||
@@ -48,6 +48,7 @@ public class Company extends AbstractJsonMapping implements IWrapperId {
|
||||
@JsonProperty("parent_company")
|
||||
private Company parentCompany = null;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -76,6 +77,7 @@ public class Company extends AbstractJsonMapping implements IWrapperId {
|
||||
return parentCompany;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import com.omertron.themoviedbapi.enumeration.MediaType;
|
||||
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
|
||||
import com.omertron.themoviedbapi.wrapper.IWrapperId;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
|
||||
/**
|
||||
* Basic media information
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public class MediaBasic extends AbstractJsonMapping implements IWrapperId {
|
||||
public class MediaBasic extends AbstractJsonMapping implements IIdentification {
|
||||
|
||||
@JsonProperty("id")
|
||||
private int id;
|
||||
@@ -46,10 +46,12 @@ public class MediaBasic extends AbstractJsonMapping implements IWrapperId {
|
||||
@JsonProperty("vote_count")
|
||||
private int voteCount;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ import com.omertron.themoviedbapi.model.media.MediaBasic;
|
||||
import com.omertron.themoviedbapi.model.movie.MovieBasic;
|
||||
import com.omertron.themoviedbapi.model.tv.TVBasic;
|
||||
import com.omertron.themoviedbapi.model.tv.TVEpisodeBasic;
|
||||
import com.omertron.themoviedbapi.wrapper.IWrapperId;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public class PersonFind extends PersonBasic implements IWrapperId {
|
||||
public class PersonFind extends PersonBasic implements IIdentification {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@JsonProperty("adult")
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.results;
|
||||
|
||||
import com.omertron.themoviedbapi.wrapper.IWrapperId;
|
||||
import com.omertron.themoviedbapi.wrapper.IWrapperPages;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
import com.omertron.themoviedbapi.interfaces.IWrapperPages;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
@@ -29,41 +29,49 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public abstract class AbstractResults implements IWrapperId, IWrapperPages {
|
||||
public abstract class AbstractResults implements IIdentification, IWrapperPages {
|
||||
|
||||
private int id = 0;
|
||||
private int page = 0;
|
||||
private int totalPages = 0;
|
||||
private int totalResults = 0;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalPages() {
|
||||
return totalPages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalResults() {
|
||||
return totalResults;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPage(int page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalPages(int totalPages) {
|
||||
this.totalPages = totalPages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalResults(int totalResults) {
|
||||
this.totalResults = totalResults;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import com.omertron.themoviedbapi.interfaces.IWrapperDates;
|
||||
import com.omertron.themoviedbapi.interfaces.IWrapperPages;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.results.AbstractResults;
|
||||
|
||||
@@ -27,7 +30,7 @@ import com.omertron.themoviedbapi.results.AbstractResults;
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId, IWrapperPages, IWrapperDates {
|
||||
public class AbstractWrapperAll extends AbstractWrapperId implements IIdentification, IWrapperPages, IWrapperDates {
|
||||
|
||||
@JsonProperty("page")
|
||||
private int page;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.results.AbstractResults;
|
||||
|
||||
@@ -27,7 +28,7 @@ import com.omertron.themoviedbapi.results.AbstractResults;
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class AbstractWrapperId extends AbstractWrapper implements IWrapperId {
|
||||
public class AbstractWrapperId extends AbstractWrapper implements IIdentification {
|
||||
|
||||
@JsonProperty("id")
|
||||
private int id;
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.omertron.themoviedbapi.model.list.UserList;
|
||||
import com.omertron.themoviedbapi.model.movie.MovieBasic;
|
||||
import com.omertron.themoviedbapi.model.tv.TVBasic;
|
||||
import com.omertron.themoviedbapi.results.ResultList;
|
||||
import com.omertron.themoviedbapi.wrapper.IWrapperId;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
import java.util.List;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -59,13 +59,13 @@ public class TestSuite {
|
||||
assertTrue("No first air date", isNotBlank(test.getFirstAirDate()));
|
||||
}
|
||||
|
||||
public static void testId(ResultList<? extends IWrapperId> result, int id, String message) {
|
||||
public static void testId(ResultList<? extends IIdentification> result, int id, String message) {
|
||||
testId(result.getResults(), id, message);
|
||||
}
|
||||
|
||||
public static void testId(List<? extends IWrapperId> result, int id, String message) {
|
||||
public static void testId(List<? extends IIdentification> result, int id, String message) {
|
||||
boolean found = false;
|
||||
for (IWrapperId item : result) {
|
||||
for (IIdentification item : result) {
|
||||
if (item.getId() == id) {
|
||||
found = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user