From 6ed9d9ea4c5781587a5de9a220a319d079dcef0a Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Tue, 14 Oct 2014 14:03:37 +0100 Subject: [PATCH] Useless parentheses around expressions should be removed to prevent any misunderstanding --- .../com/omertron/themoviedbapi/TheMovieDbApi.java | 6 +++--- .../themoviedbapi/model/AlternativeTitle.java | 5 ++--- .../com/omertron/themoviedbapi/model/Artwork.java | 4 ++-- .../omertron/themoviedbapi/model/Collection.java | 6 +++--- .../com/omertron/themoviedbapi/model/Discover.java | 11 ++++++----- .../com/omertron/themoviedbapi/model/Genre.java | 2 +- .../com/omertron/themoviedbapi/model/Keyword.java | 2 +- .../com/omertron/themoviedbapi/model/Language.java | 4 ++-- .../com/omertron/themoviedbapi/model/MovieDb.java | 14 +++++++++++--- .../com/omertron/themoviedbapi/model/Person.java | 13 ++++++------- .../omertron/themoviedbapi/model/PersonCast.java | 6 +++--- .../omertron/themoviedbapi/model/PersonCrew.java | 6 +++--- .../themoviedbapi/model/ProductionCompany.java | 2 +- .../themoviedbapi/model/ProductionCountry.java | 4 ++-- .../omertron/themoviedbapi/model/ReleaseInfo.java | 6 +++--- .../themoviedbapi/model/TmdbConfiguration.java | 7 +++---- .../com/omertron/themoviedbapi/model/Trailer.java | 6 +++--- .../omertron/themoviedbapi/model/Translation.java | 6 +++--- .../comparator/PersonCreditDateComparator.java | 4 ++-- 19 files changed, 60 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 1eba9f76f..7888ff760 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -339,7 +339,7 @@ public class TheMovieDbApi { * @param distance */ private static boolean compareDistance(String title1, String title2, int distance) { - return (StringUtils.getLevenshteinDistance(title1, title2) <= distance); + return StringUtils.getLevenshteinDistance(title1, title2) <= distance; } /** @@ -348,7 +348,7 @@ public class TheMovieDbApi { * @param year */ private static boolean isValidYear(String year) { - return (StringUtils.isNotBlank(year) && !"UNKNOWN".equals(year)); + return StringUtils.isNotBlank(year) && !"UNKNOWN".equals(year); } // @@ -378,7 +378,7 @@ public class TheMovieDbApi { sb.append(requiredSize); sb.append(imagePath); try { - return (new URL(sb.toString())); + return new URL(sb.toString()); } catch (MalformedURLException ex) { LOG.warn("Failed to create image URL: {}", ex.getMessage(), ex); throw new MovieDbException(MovieDbExceptionType.INVALID_URL, sb.toString(), "", ex); diff --git a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java index 4a63f0b77..14eb3c984 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java +++ b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java @@ -20,7 +20,6 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonProperty; - import java.io.Serializable; /** @@ -67,10 +66,10 @@ public class AlternativeTitle implements Serializable { return false; } final AlternativeTitle other = (AlternativeTitle) obj; - if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) { + if (this.country == null ? other.country != null : !this.country.equals(other.country)) { return false; } - if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { + if (this.title == null ? other.title != null : !this.title.equals(other.title)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java index 96c837139..519342604 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java @@ -142,13 +142,13 @@ public class Artwork extends AbstractJsonMapping { if (Float.floatToIntBits(this.aspectRatio) != Float.floatToIntBits(other.aspectRatio)) { return false; } - if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) { + if (this.filePath == null ? other.filePath != null : !this.filePath.equals(other.filePath)) { return false; } if (this.height != other.height) { return false; } - if ((this.language == null) ? (other.language != null) : !this.language.equals(other.language)) { + if (this.language == null ? other.language != null : !this.language.equals(other.language)) { return false; } if (this.width != other.width) { diff --git a/src/main/java/com/omertron/themoviedbapi/model/Collection.java b/src/main/java/com/omertron/themoviedbapi/model/Collection.java index 93faf3d19..4bdefa61b 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Collection.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Collection.java @@ -110,16 +110,16 @@ public class Collection extends AbstractJsonMapping { return false; } final Collection other = (Collection) obj; - if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) { + if (this.backdropPath == null ? other.backdropPath != null : !this.backdropPath.equals(other.backdropPath)) { return false; } if (this.id != other.id) { return false; } - if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { + if (this.title == null ? other.title != null : !this.title.equals(other.title)) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Discover.java b/src/main/java/com/omertron/themoviedbapi/model/Discover.java index 4996e068e..8eec1628e 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Discover.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Discover.java @@ -19,12 +19,13 @@ */ package com.omertron.themoviedbapi.model; -import org.apache.commons.lang3.StringUtils; - +import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_ADULT; +import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_LANGUAGE; +import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_PAGE; +import static com.omertron.themoviedbapi.tools.ApiUrl.PARAM_YEAR; import java.util.HashMap; import java.util.Map; - -import static com.omertron.themoviedbapi.tools.ApiUrl.*; +import org.apache.commons.lang3.StringUtils; /** * Generate a discover object for use in the MovieDbApi @@ -273,6 +274,6 @@ public class Discover { * @return */ private boolean checkYear(int year) { - return (year >= YEAR_MIN && year <= YEAR_MAX); + return year >= YEAR_MIN && year <= YEAR_MAX; } } diff --git a/src/main/java/com/omertron/themoviedbapi/model/Genre.java b/src/main/java/com/omertron/themoviedbapi/model/Genre.java index d3250687d..d9bcdf3b2 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Genre.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Genre.java @@ -65,7 +65,7 @@ public class Genre extends AbstractJsonMapping { if (this.id != other.id) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java index af652a6f9..be4dd599f 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java @@ -66,7 +66,7 @@ public class Keyword extends AbstractJsonMapping { if (this.id != other.id) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Language.java b/src/main/java/com/omertron/themoviedbapi/model/Language.java index efdcfe81f..9a6289ef5 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Language.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Language.java @@ -62,10 +62,10 @@ public class Language extends AbstractJsonMapping { return false; } final Language other = (Language) obj; - if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { + if (this.isoCode == null ? other.isoCode != null : !this.isoCode.equals(other.isoCode)) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java index d8556af85..f15fb29ac 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java @@ -20,8 +20,16 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.wrapper.*; - +import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; +import com.omertron.themoviedbapi.wrapper.WrapperImages; +import com.omertron.themoviedbapi.wrapper.WrapperMovie; +import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts; +import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords; +import com.omertron.themoviedbapi.wrapper.WrapperMovieList; +import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo; +import com.omertron.themoviedbapi.wrapper.WrapperReviews; +import com.omertron.themoviedbapi.wrapper.WrapperTrailers; +import com.omertron.themoviedbapi.wrapper.WrapperTranslations; import java.util.List; /** @@ -399,7 +407,7 @@ public class MovieDb extends AbstractJsonMapping { if (this.id != other.id) { return false; } - if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { + if (this.imdbID == null ? other.imdbID != null : !this.imdbID.equals(other.imdbID)) { return false; } if (this.runtime != other.runtime) { diff --git a/src/main/java/com/omertron/themoviedbapi/model/Person.java b/src/main/java/com/omertron/themoviedbapi/model/Person.java index d0dce83cd..342f148fd 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Person.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Person.java @@ -20,10 +20,9 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.StringUtils; - import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.StringUtils; /** * @author stuart.boston @@ -274,22 +273,22 @@ public class Person extends AbstractJsonMapping { if (this.id != other.id) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } - if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { + if (this.profilePath == null ? other.profilePath != null : !this.profilePath.equals(other.profilePath)) { return false; } if (this.personType != other.personType) { return false; } - if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) { + if (this.department == null ? other.department != null : !this.department.equals(other.department)) { return false; } - if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) { + if (this.job == null ? other.job != null : !this.job.equals(other.job)) { return false; } - if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) { + if (this.character == null ? other.character != null : !this.character.equals(other.character)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java index daa3c4b8a..d60a565f2 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java @@ -115,16 +115,16 @@ public class PersonCast extends AbstractJsonMapping { if (this.id != other.id) { return false; } - if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) { + if (this.character == null ? other.character != null : !this.character.equals(other.character)) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } if (this.order != other.order) { return false; } - if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { + if (this.profilePath == null ? other.profilePath != null : !this.profilePath.equals(other.profilePath)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java index a5d60f787..7ab62872a 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java @@ -105,13 +105,13 @@ public class PersonCrew extends AbstractJsonMapping { if (this.id != other.id) { return false; } - if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) { + if (this.department == null ? other.department != null : !this.department.equals(other.department)) { return false; } - if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) { + if (this.job == null ? other.job != null : !this.job.equals(other.job)) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java index f765e8bea..8885a6082 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java @@ -66,7 +66,7 @@ public class ProductionCompany extends AbstractJsonMapping { if (this.id != other.id) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java index 573aeb121..e36a5f91d 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java @@ -63,10 +63,10 @@ public class ProductionCountry extends AbstractJsonMapping { return false; } final ProductionCountry other = (ProductionCountry) obj; - if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { + if (this.isoCode == null ? other.isoCode != null : !this.isoCode.equals(other.isoCode)) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java index 10d233d7b..95246b8f0 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java @@ -71,13 +71,13 @@ public class ReleaseInfo extends AbstractJsonMapping { return false; } final ReleaseInfo other = (ReleaseInfo) obj; - if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) { + if (this.country == null ? other.country != null : !this.country.equals(other.country)) { return false; } - if ((this.certification == null) ? (other.certification != null) : !this.certification.equals(other.certification)) { + if (this.certification == null ? other.certification != null : !this.certification.equals(other.certification)) { return false; } - if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { + if (this.releaseDate == null ? other.releaseDate != null : !this.releaseDate.equals(other.releaseDate)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java index 912d80761..128072d77 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java @@ -20,9 +20,8 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.StringUtils; - import java.util.List; +import org.apache.commons.lang3.StringUtils; /** * @author stuart.boston @@ -176,9 +175,9 @@ public class TmdbConfiguration extends AbstractJsonMapping { * @return */ public boolean isValidSize(String sizeToCheck) { - return (isValidPosterSize(sizeToCheck) + return isValidPosterSize(sizeToCheck) || isValidBackdropSize(sizeToCheck) || isValidProfileSize(sizeToCheck) - || isValidLogoSize(sizeToCheck)); + || isValidLogoSize(sizeToCheck); } } diff --git a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java index e6d3fbd2b..680c0f830 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java @@ -90,13 +90,13 @@ public class Trailer extends AbstractJsonMapping { return false; } final Trailer other = (Trailer) obj; - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } - if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) { + if (this.size == null ? other.size != null : !this.size.equals(other.size)) { return false; } - if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) { + if (this.source == null ? other.source != null : !this.source.equals(other.source)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Translation.java b/src/main/java/com/omertron/themoviedbapi/model/Translation.java index d219cef91..aad473cc7 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Translation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Translation.java @@ -73,13 +73,13 @@ public class Translation extends AbstractJsonMapping { return false; } final Translation other = (Translation) obj; - if ((this.englishName == null) ? (other.englishName != null) : !this.englishName.equals(other.englishName)) { + if (this.englishName == null ? other.englishName != null : !this.englishName.equals(other.englishName)) { return false; } - if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { + if (this.isoCode == null ? other.isoCode != null : !this.isoCode.equals(other.isoCode)) { return false; } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + if (this.name == null ? other.name != null : !this.name.equals(other.name)) { return false; } return true; diff --git a/src/main/java/com/omertron/themoviedbapi/model/comparator/PersonCreditDateComparator.java b/src/main/java/com/omertron/themoviedbapi/model/comparator/PersonCreditDateComparator.java index c70380b81..5f7cc175a 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/comparator/PersonCreditDateComparator.java +++ b/src/main/java/com/omertron/themoviedbapi/model/comparator/PersonCreditDateComparator.java @@ -76,7 +76,7 @@ public class PersonCreditDateComparator implements Comparator, Ser int year1 = extractYear(pc1.getReleaseDate()); int year2 = extractYear(pc2.getReleaseDate()); - return ascending ? (year1 - year2) : (year2 - year1); + return ascending ? year1 - year2 : year2 - year1; } /** @@ -89,7 +89,7 @@ public class PersonCreditDateComparator implements Comparator, Ser int year = 0; Matcher m = YEAR_PATTERN.matcher(date); if (m.find()) { - year = Integer.valueOf(m.group(1)).intValue(); + year = Integer.parseInt(m.group(1)); } // Give up and return 0