Use diamond interface

This commit is contained in:
Stuart Boston
2015-06-01 11:37:54 +01:00
parent 0aab56a044
commit 4f9d74c9f7
12 changed files with 54 additions and 82 deletions
@@ -157,4 +157,5 @@ public class TmdbAuthentication extends AbstractMethod {
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Guest Session Token", url, ex);
}
}}
}
}
@@ -65,7 +65,7 @@ public class TmdbCertifications extends AbstractMethod {
JsonNode node = MAPPER.readTree(webpage);
Map<String, List<Certification>> results = MAPPER.readValue(node.elements().next().traverse(), new TypeReference<Map<String, List<Certification>>>() {
});
return new ResultsMap<String, List<Certification>>(results);
return new ResultsMap<>(results);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie certifications", url, ex);
}
@@ -85,7 +85,7 @@ public class TmdbCertifications extends AbstractMethod {
JsonNode node = MAPPER.readTree(webpage);
Map<String, List<Certification>> results = MAPPER.readValue(node.elements().next().traverse(), new TypeReference<Map<String, List<Certification>>>() {
});
return new ResultsMap<String, List<Certification>>(results);
return new ResultsMap<>(results);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV certifications", url, ex);
}
@@ -53,11 +53,9 @@ public class TmdbCollections extends AbstractMethod {
}
/**
* This method is used to retrieve all of the basic information about a
* movie collection.
* This method is used to retrieve all of the basic information about a movie collection.
*
* You can get the ID needed for this method by making a getMovieInfo
* request for the belongs_to_collection.
* You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection.
*
* @param collectionId
* @param language
@@ -97,7 +95,7 @@ public class TmdbCollections extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll(ArtworkType.POSTER, ArtworkType.BACKDROP));
ResultList<Artwork> results = new ResultList<>(wrapper.getAll(ArtworkType.POSTER, ArtworkType.BACKDROP));
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -95,7 +95,7 @@ public class TmdbConfiguration extends AbstractMethod {
try {
WrapperJobList wrapper = MAPPER.readValue(webpage, WrapperJobList.class);
ResultList<JobDepartment> results = new ResultList<JobDepartment>(wrapper.getJobs());
ResultList<JobDepartment> results = new ResultList<>(wrapper.getJobs());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -121,7 +121,7 @@ public class TmdbConfiguration extends AbstractMethod {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get timezone list", url, ex);
}
ResultsMap<String, List<String>> timezones = new ResultsMap<String, List<String>>();
ResultsMap<String, List<String>> timezones = new ResultsMap<>();
for (Map<String, List<String>> tzMap : tzList) {
for (Map.Entry<String, List<String>> x : tzMap.entrySet()) {
@@ -28,7 +28,6 @@ import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import java.io.IOException;
import java.net.URL;
import org.slf4j.LoggerFactory;
import org.yamj.api.common.exception.ApiExceptionType;
/**
@@ -53,14 +52,11 @@ public class TmdbCredits extends AbstractMethod {
* <p>
* This is currently only supported with the new credit model found in TV.
* <br/>
* These IDs can be found from any TV credit response as well as the
* TV_credits and combined_credits methods for people. <br/>
* The episodes object returns a list of episodes and are generally going to
* be guest stars. <br/>
* These IDs can be found from any TV credit response as well as the TV_credits and combined_credits methods for people. <br/>
* The episodes object returns a list of episodes and are generally going to be guest stars. <br/>
* The season array will return a list of season numbers. <br/>
* Season credits are credits that were marked with the "add to every
* season" option in the editing interface and are assumed to be "season
* regulars".
* Season credits are credits that were marked with the "add to every season" option in the editing interface and are assumed to
* be "season regulars".
*
* @param creditId
* @param language
@@ -78,7 +74,6 @@ public class TmdbCredits extends AbstractMethod {
try {
return MAPPER.readValue(webpage, CreditInfo.class);
} catch (IOException ex) {
LoggerFactory.getLogger("test").info("{}",ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get credit info", url, ex);
}
}
@@ -42,7 +42,6 @@ import com.omertron.themoviedbapi.results.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperVideos;
import java.io.IOException;
import java.net.URL;
import org.slf4j.LoggerFactory;
import org.yamj.api.common.exception.ApiExceptionType;
/**
@@ -89,7 +88,6 @@ public class TmdbEpisodes extends AbstractMethod {
try {
return MAPPER.readValue(webpage, TVEpisodeInfo.class);
} catch (IOException ex) {
LoggerFactory.getLogger("test").warn("{}", ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV Episode Info", url, ex);
}
}
@@ -207,7 +205,7 @@ public class TmdbEpisodes extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll());
ResultList<Artwork> results = new ResultList<>(wrapper.getAll());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -274,7 +272,7 @@ public class TmdbEpisodes extends AbstractMethod {
try {
WrapperVideos wrapper = MAPPER.readValue(webpage, WrapperVideos.class);
ResultList<Video> results = new ResultList<Video>(wrapper.getVideos());
ResultList<Video> results = new ResultList<>(wrapper.getVideos());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -91,7 +91,7 @@ public class TmdbGenres extends AbstractMethod {
try {
WrapperGenres wrapper = MAPPER.readValue(webpage, WrapperGenres.class);
ResultList<Genre> results = new ResultList<Genre>(wrapper.getGenres());
ResultList<Genre> results = new ResultList<>(wrapper.getGenres());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -78,8 +78,7 @@ public class TmdbMovies extends AbstractMethod {
*
* It will return the single highest rated poster and backdrop.
*
* ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies
* found.
* ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found.
*
* @param movieId
* @param language
@@ -111,8 +110,7 @@ public class TmdbMovies extends AbstractMethod {
*
* It will return the single highest rated poster and backdrop.
*
* ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies
* found.
* ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found.
*
* @param imdbId
* @param language
@@ -141,8 +139,8 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method lets a user get the status of whether or not the movie has
* been rated or added to their favourite or movie watch list.
* This method lets a user get the status of whether or not the movie has been rated or added to their favourite or movie watch
* list.
*
* A valid session id is required.
*
@@ -167,8 +165,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve all of the alternative titles we have for
* a particular movie.
* This method is used to retrieve all of the alternative titles we have for a particular movie.
*
* @param movieId
* @param country
@@ -184,7 +181,7 @@ public class TmdbMovies extends AbstractMethod {
String webpage = httpTools.getRequest(url);
try {
WrapperAlternativeTitles wrapper = MAPPER.readValue(webpage, WrapperAlternativeTitles.class);
ResultList<AlternativeTitle> results = new ResultList<AlternativeTitle>(wrapper.getTitles());
ResultList<AlternativeTitle> results = new ResultList<>(wrapper.getTitles());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -213,8 +210,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method should be used when youre wanting to retrieve all of the
* images for a particular movie.
* This method should be used when youre wanting to retrieve all of the images for a particular movie.
*
* @param movieId
* @param language
@@ -231,7 +227,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll());
ResultList<Artwork> results = new ResultList<>(wrapper.getAll());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -240,8 +236,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve all of the keywords that have been added
* to a particular movie.
* This method is used to retrieve all of the keywords that have been added to a particular movie.
*
* Currently, only English keywords exist.
*
@@ -258,7 +253,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperMovieKeywords wrapper = MAPPER.readValue(webpage, WrapperMovieKeywords.class);
ResultList<Keyword> results = new ResultList<Keyword>(wrapper.getKeywords());
ResultList<Keyword> results = new ResultList<>(wrapper.getKeywords());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -267,8 +262,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve all of the release and certification data
* we have for a specific movie.
* This method is used to retrieve all of the release and certification data we have for a specific movie.
*
* @param movieId
* @param language
@@ -285,7 +279,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperReleaseInfo wrapper = MAPPER.readValue(webpage, WrapperReleaseInfo.class);
ResultList<ReleaseInfo> results = new ResultList<ReleaseInfo>(wrapper.getCountries());
ResultList<ReleaseInfo> results = new ResultList<>(wrapper.getCountries());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -294,8 +288,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve all of the trailers for a particular
* movie.
* This method is used to retrieve all of the trailers for a particular movie.
*
* Supported sites are YouTube and QuickTime.
*
@@ -314,7 +307,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperVideos wrapper = MAPPER.readValue(webpage, WrapperVideos.class);
ResultList<Video> results = new ResultList<Video>(wrapper.getVideos());
ResultList<Video> results = new ResultList<>(wrapper.getVideos());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -323,8 +316,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve a list of the available translations for
* a specific movie.
* This method is used to retrieve a list of the available translations for a specific movie.
*
* @param movieId
* @return
@@ -339,7 +331,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperTranslations wrapper = MAPPER.readValue(webpage, WrapperTranslations.class);
ResultList<Translation> results = new ResultList<Translation>(wrapper.getTranslations());
ResultList<Translation> results = new ResultList<>(wrapper.getTranslations());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -348,11 +340,9 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* The similar movies method will let you retrieve the similar movies for a
* particular movie.
* The similar movies method will let you retrieve the similar movies for a particular movie.
*
* This data is created dynamically but with the help of users votes on
* TMDb.
* This data is created dynamically but with the help of users votes on TMDb.
*
* The data is much better with movies that have more keywords
*
@@ -420,8 +410,7 @@ public class TmdbMovies extends AbstractMethod {
*
* By default, only the last 24 hours of changes are returned.
*
* The maximum number of days that can be returned in a single request is
* 14.
* The maximum number of days that can be returned in a single request is 14.
*
* The language is present on fields that are translatable.
*
@@ -513,8 +502,7 @@ public class TmdbMovies extends AbstractMethod {
/**
* This method is used to retrieve the movies currently in theatres.
*
* This is a curated list that will normally contain 100 movies. The default
* response will return 20 movies.
* This is a curated list that will normally contain 100 movies. The default response will return 20 movies.
*
* @param language
* @param page
@@ -552,8 +540,7 @@ public class TmdbMovies extends AbstractMethod {
}
/**
* This method is used to retrieve the top rated movies that have over 10
* votes on TMDb.
* This method is used to retrieve the top rated movies that have over 10 votes on TMDb.
*
* The default response will return 20 movies.
*
@@ -203,13 +203,14 @@ public class TmdbSearch extends AbstractMethod {
try {
WrapperMultiSearch wrapper = MAPPER.readValue(webpage, WrapperMultiSearch.class);
ResultList<MediaBasic> results = new ResultList<MediaBasic>();
ResultList<MediaBasic> results = new ResultList<>();
results.getResults().addAll(wrapper.getResults());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get multi search", url, ex);
} }
}
}
/**
* This is a good starting point to start finding people on TMDb.
@@ -99,8 +99,7 @@ public class TmdbSeasons extends AbstractMethod {
}
/**
* This method lets users get the status of whether or not the TV episodes
* of a season have been rated.
* This method lets users get the status of whether or not the TV episodes of a season have been rated.
*
* A valid session id is required.
*
@@ -147,8 +146,7 @@ public class TmdbSeasons extends AbstractMethod {
}
/**
* Get the external ids that we have stored for a TV season by season
* number.
* Get the external ids that we have stored for a TV season by season number.
*
* @param tvID
* @param seasonNumber
@@ -194,7 +192,7 @@ public class TmdbSeasons extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll());
ResultList<Artwork> results = new ResultList<>(wrapper.getAll());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -203,8 +201,7 @@ public class TmdbSeasons extends AbstractMethod {
}
/**
* Get the videos that have been added to a TV season (trailers, teasers,
* etc...)
* Get the videos that have been added to a TV season (trailers, teasers, etc...)
*
* @param tvID
* @param seasonNumber
@@ -223,7 +220,7 @@ public class TmdbSeasons extends AbstractMethod {
try {
WrapperVideos wrapper = MAPPER.readValue(webpage, WrapperVideos.class);
ResultList<Video> results = new ResultList<Video>(wrapper.getVideos());
ResultList<Video> results = new ResultList<>(wrapper.getVideos());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -96,8 +96,8 @@ public class TmdbTV extends AbstractMethod {
}
/**
* This method lets users get the status of whether or not the TV show has
* been rated or added to their favourite or watch lists.
* This method lets users get the status of whether or not the TV show has been rated or added to their favourite or watch
* lists.
*
* A valid session id is required.
*
@@ -231,7 +231,7 @@ public class TmdbTV extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll());
ResultList<Artwork> results = new ResultList<>(wrapper.getAll());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -311,8 +311,7 @@ public class TmdbTV extends AbstractMethod {
}
/**
* Get the list of translations that exist for a TV series. These
* translations cascade down to the episode level.
* Get the list of translations that exist for a TV series. These translations cascade down to the episode level.
*
* @param tvID
* @return
@@ -327,7 +326,7 @@ public class TmdbTV extends AbstractMethod {
try {
WrapperTranslations wrapper = MAPPER.readValue(webpage, WrapperTranslations.class);
ResultList<Translation> results = new ResultList<Translation>(wrapper.getTranslations());
ResultList<Translation> results = new ResultList<>(wrapper.getTranslations());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -336,8 +335,7 @@ public class TmdbTV extends AbstractMethod {
}
/**
* Get the videos that have been added to a TV series (trailers, opening
* credits, etc...)
* Get the videos that have been added to a TV series (trailers, opening credits, etc...)
*
* @param tvID
* @param language
@@ -354,7 +352,7 @@ public class TmdbTV extends AbstractMethod {
try {
WrapperVideos wrapper = MAPPER.readValue(webpage, WrapperVideos.class);
ResultList<Video> results = new ResultList<Video>(wrapper.getVideos());
ResultList<Video> results = new ResultList<>(wrapper.getVideos());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -382,8 +380,7 @@ public class TmdbTV extends AbstractMethod {
/**
* Get the list of TV shows that are currently on the air.
*
* This query looks for any TV show that has an episode with an air date in
* the next 7 days.
* This query looks for any TV show that has an episode with an air date in the next 7 days.
*
* @param page
* @param language
@@ -425,8 +422,7 @@ public class TmdbTV extends AbstractMethod {
/**
* Get the list of top rated TV shows.
*
* By default, this list will only include TV shows that have 2 or more
* votes.
* By default, this list will only include TV shows that have 2 or more votes.
*
* This list refreshes every day.
*
@@ -66,7 +66,6 @@ public class PersonInfo extends PersonBasic implements Serializable, AppendToRes
private final Set<PeopleMethod> methods = EnumSet.noneOf(PeopleMethod.class);
// AppendToResponse Properties
private List<ChangeKeyItem> changes = Collections.emptyList();
// TODO: Add COMBINED_CREDITS
private ExternalID externalIDs = new ExternalID();
private List<Artwork> images = Collections.emptyList();
private List<ArtworkMedia> taggedImages = Collections.emptyList();