Refactor wrappers

master
Stuart Boston 11 years ago
parent e5f2f1eaa9
commit 28c814c1f0

@ -19,7 +19,7 @@
*/
package com.omertron.themoviedbapi.interfaces;
import com.omertron.themoviedbapi.wrapper.ResultDates;
import com.omertron.themoviedbapi.results.ResultDates;
public interface IWrapperDates {

@ -45,8 +45,8 @@ import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperChanges;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperChanges;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;

@ -36,7 +36,7 @@ import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.PostBody;
import com.omertron.themoviedbapi.tools.PostTools;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -28,7 +28,7 @@ import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import java.net.URL;
/**

@ -30,7 +30,7 @@ import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperImages;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -29,7 +29,7 @@ import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -30,8 +30,8 @@ import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.wrapper.WrapperConfig;
import com.omertron.themoviedbapi.wrapper.WrapperJobList;
import com.omertron.themoviedbapi.results.WrapperConfig;
import com.omertron.themoviedbapi.results.WrapperJobList;
import java.io.IOException;
import java.net.URL;
import java.util.List;

@ -28,7 +28,7 @@ import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import java.net.URL;
/**

@ -38,8 +38,8 @@ import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.PostBody;
import com.omertron.themoviedbapi.tools.PostTools;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperVideos;
import com.omertron.themoviedbapi.results.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperVideos;
import java.io.IOException;
import java.net.URL;
import org.slf4j.LoggerFactory;

@ -29,8 +29,8 @@ import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.wrapper.WrapperGenres;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperGenres;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -29,7 +29,7 @@ import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -43,13 +43,13 @@ import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.PostBody;
import com.omertron.themoviedbapi.tools.PostTools;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords;
import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo;
import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
import com.omertron.themoviedbapi.wrapper.WrapperVideos;
import com.omertron.themoviedbapi.results.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperMovieKeywords;
import com.omertron.themoviedbapi.results.WrapperReleaseInfo;
import com.omertron.themoviedbapi.results.WrapperTranslations;
import com.omertron.themoviedbapi.results.WrapperVideos;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -42,8 +42,8 @@ import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperImages;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -37,8 +37,8 @@ import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.wrapper.WrapperMultiSearch;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperMultiSearch;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -35,8 +35,8 @@ import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperVideos;
import com.omertron.themoviedbapi.results.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperVideos;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -43,10 +43,10 @@ import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.PostBody;
import com.omertron.themoviedbapi.tools.PostTools;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
import com.omertron.themoviedbapi.wrapper.WrapperVideos;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperTranslations;
import com.omertron.themoviedbapi.results.WrapperVideos;
import java.io.IOException;
import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;

@ -36,13 +36,13 @@ import com.omertron.themoviedbapi.model.media.MediaCreditCast;
import com.omertron.themoviedbapi.model.media.MediaCreditCrew;
import com.omertron.themoviedbapi.model.media.MediaCreditList;
import com.omertron.themoviedbapi.model.review.Review;
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords;
import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo;
import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
import com.omertron.themoviedbapi.wrapper.WrapperVideos;
import com.omertron.themoviedbapi.results.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.results.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperMovieKeywords;
import com.omertron.themoviedbapi.results.WrapperReleaseInfo;
import com.omertron.themoviedbapi.results.WrapperTranslations;
import com.omertron.themoviedbapi.results.WrapperVideos;
import java.util.List;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

@ -17,65 +17,28 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
package com.omertron.themoviedbapi.results;
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;
/**
* Base class for the wrappers
*
* @author Stuart
*/
public class AbstractWrapperAll extends AbstractWrapperId implements IIdentification, IWrapperPages, IWrapperDates {
public class AbstractWrapperAll extends AbstractWrapperIdPages implements IIdentification, IWrapperPages, IWrapperDates {
@JsonProperty("page")
private int page;
@JsonProperty("total_pages")
private int totalPages;
@JsonProperty("total_results")
private int totalResults;
@JsonProperty("dates")
private ResultDates dates = new ResultDates();
@Override
public int getPage() {
return page;
}
@Override
public int getTotalPages() {
return totalPages;
}
@Override
public int getTotalResults() {
return totalResults;
}
@Override
public ResultDates getDates() {
return dates;
}
@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;
}
@Override
public void setDates(ResultDates dates) {
this.dates = dates;
@ -87,10 +50,7 @@ public class AbstractWrapperAll extends AbstractWrapperId implements IIdentifica
* @param results
*/
@Override
public void setResultProperties(AbstractResults results) {
public void setResultProperties(AbstractWrapperIdPages results) {
super.setResultProperties(results);
results.setPage(page);
results.setTotalPages(totalPages);
results.setTotalResults(totalResults);
}
}

@ -17,16 +17,15 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
package com.omertron.themoviedbapi.results;
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import com.omertron.themoviedbapi.results.AbstractResults;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
public abstract class AbstractWrapper extends AbstractJsonMapping {
public abstract class AbstractWrapperBase extends AbstractJsonMapping {
/**
* Get a list of the enums passed
@ -49,7 +48,7 @@ public abstract class AbstractWrapper extends AbstractJsonMapping {
*
* @param results
*/
public void setResultProperties(AbstractResults results) {
public void setResultProperties(AbstractWrapperIdPages results) {
// There are no values to copy
results.setId(0);
results.setPage(0);

@ -17,18 +17,17 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
package com.omertron.themoviedbapi.results;
import com.omertron.themoviedbapi.interfaces.IIdentification;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.results.AbstractResults;
/**
* Base class for the wrappers
*
* @author Stuart
*/
public class AbstractWrapperId extends AbstractWrapper implements IIdentification {
public class AbstractWrapperId extends AbstractWrapperBase implements IIdentification {
@JsonProperty("id")
private int id;
@ -49,7 +48,7 @@ public class AbstractWrapperId extends AbstractWrapper implements IIdentificatio
* @param results
*/
@Override
public void setResultProperties(AbstractResults results) {
public void setResultProperties(AbstractWrapperIdPages results) {
super.setResultProperties(results);
results.setId(id);
}

@ -19,28 +19,19 @@
*/
package com.omertron.themoviedbapi.results;
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;
/**
* Abstract class to return the results and the id/page info
*
* @author Stuart
*/
public abstract class AbstractResults implements IIdentification, IWrapperPages {
public abstract class AbstractWrapperIdPages extends AbstractWrapperId implements 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;
@ -56,11 +47,6 @@ public abstract class AbstractResults implements IIdentification, IWrapperPages
return totalResults;
}
@Override
public void setId(int id) {
this.id = id;
}
@Override
public void setPage(int page) {
this.page = page;
@ -76,8 +62,16 @@ public abstract class AbstractResults implements IIdentification, IWrapperPages
this.totalResults = totalResults;
}
/**
* Copy the wrapper values to the results
*
* @param results
*/
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
public void setResultProperties(AbstractWrapperIdPages results) {
super.setResultProperties(results);
results.setPage(page);
results.setTotalPages(totalPages);
results.setTotalResults(totalResults);
}
}

@ -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.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.AbstractJsonMapping;

@ -31,7 +31,7 @@ import java.util.List;
* @author Stuart
* @param <T>
*/
public final class ResultList<T> extends AbstractResults {
public final class ResultList<T> extends AbstractWrapperIdPages {
private List<T> results;

@ -32,7 +32,7 @@ import java.util.Map;
* @param <K>
* @param <V>
*/
public final class ResultsMap<K, V> extends AbstractResults {
public final class ResultsMap<K, V> extends AbstractWrapperIdPages {
private Map<K, V> results;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.media.AlternativeTitle;

@ -17,14 +17,14 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
package com.omertron.themoviedbapi.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.change.ChangeKeyItem;
import java.util.ArrayList;
import java.util.List;
public class WrapperChanges extends AbstractWrapper {
public class WrapperChanges extends AbstractWrapperBase {
@JsonProperty("changes")
private List<ChangeKeyItem> changedItems = new ArrayList<ChangeKeyItem>();

@ -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.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.config.Configuration;
@ -28,7 +28,7 @@ import java.util.List;
*
* @author Stuart
*/
public class WrapperConfig extends AbstractWrapper {
public class WrapperConfig extends AbstractWrapperBase {
@JsonProperty("images")
private Configuration tmdbConfiguration;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Genre;
@ -28,7 +28,7 @@ import java.util.List;
*
* @author Stuart
*/
public class WrapperGenres extends AbstractWrapper {
public class WrapperGenres extends AbstractWrapperBase {
@JsonProperty("genres")
private List<Genre> genres;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.enumeration.ArtworkType;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.config.JobDepartment;
@ -27,7 +27,7 @@ import java.util.List;
*
* @author Stuart
*/
public class WrapperJobList extends AbstractWrapper {
public class WrapperJobList extends AbstractWrapperBase {
@JsonProperty("jobs")
private List<JobDepartment> jobs;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.keyword.Keyword;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.JsonSubTypes;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.movie.ReleaseInfo;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.media.Translation;

@ -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.results;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.omertron.themoviedbapi.model.media.Trailer;
Loading…
Cancel
Save