Added new classes to return the results

This commit is contained in:
Stuart Boston
2013-05-18 11:23:44 +01:00
parent edf4518f35
commit 009e725cb6
4 changed files with 175 additions and 1 deletions
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.results;
import com.omertron.themoviedbapi.wrapper.AbstractWrapperAll;
import com.omertron.themoviedbapi.wrapper.AbstractWrapperId;
/**
* Abstract class to return the results and the id/page info
* @author Stuart
*/
public abstract class TmdbResults {
private int id = 0;
private int page = 0;
private int totalPages = 0;
private int totalResults = 0;
//<editor-fold defaultstate="collapsed" desc="Getters">
public int getId() {
return id;
}
public int getPage() {
return page;
}
public int getTotalPages() {
return totalPages;
}
public int getTotalResults() {
return totalResults;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setters">
public void setId(int id) {
this.id = id;
}
public void setPage(int page) {
this.page = page;
}
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
//</editor-fold>
/**
* Copy the Id from the wrapper
*
* @param wrapper
*/
public void copyWrapper(AbstractWrapperId wrapper) {
this.id = wrapper.getId();
}
/**
* Copy the Id and pages from the wrapper
*
* @param wrapper
*/
public void copyWrapper(AbstractWrapperAll wrapper) {
this.id = wrapper.getId();
this.page = wrapper.getPage();
this.totalPages = wrapper.getTotalPages();
this.totalResults = wrapper.getTotalResults();
}
}
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.results;
import java.util.Collections;
import java.util.List;
/**
* List of the results from TheMovieDb
* @author Stuart
* @param <T>
*/
public final class TmdbResultsList<T> extends TmdbResults {
private List<T> results = Collections.EMPTY_LIST;
public List<T> getResults() {
return results;
}
public void setResults(List<T> results) {
this.results = results;
}
}
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.results;
import java.util.Collections;
import java.util.Map;
/**
* Map of the results from TheMovieDb
* @author Stuart
* @param <K>
* @param <V>
*/
public final class TmdbResultsMap<K, V> extends TmdbResults {
private Map<K, V> results = Collections.EMPTY_MAP;
public Map<K, V> getResults() {
return results;
}
public void setResults(Map<K, V> results) {
this.results = results;
}
}
@@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDb;
import java.util.List;
import org.slf4j.LoggerFactory;
/**
*