@@ -276,35 +276,50 @@ public BookMetadata extractMetadata(File epubFile) {
276276
277277 String key = StringUtils .isNotBlank (prop ) ? prop : name ;
278278
279- if (key .equals (BookLoreMetadata .NS_PREFIX + ":asin" )) builderMeta .asin (content );
280- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":goodreads_id" )) builderMeta .goodreadsId (content );
281- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":comicvine_id" )) builderMeta .comicvineId (content );
282- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":ranobedb_id" )) builderMeta .ranobedbId (content );
283- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":hardcover_id" )) builderMeta .hardcoverId (content );
284- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":google_books_id" )) builderMeta .googleId (content );
285- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":lubimyczytac_id" )) builderMeta .lubimyczytacId (content );
286- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":page_count" )) safeParseInt (content , builderMeta ::pageCount );
287- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":subtitle" )) builderMeta .subtitle (content );
288- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":series_total" )) safeParseInt (content , builderMeta ::seriesTotal );
289- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":rating" )) { /* Generic rating not supported */ }
290- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":amazon_rating" )) safeParseDouble (content , builderMeta ::amazonRating );
291- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":amazon_review_count" )) safeParseInt (content , builderMeta ::amazonReviewCount );
292- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":goodreads_rating" )) safeParseDouble (content , builderMeta ::goodreadsRating );
293- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":goodreads_review_count" )) safeParseInt (content , builderMeta ::goodreadsReviewCount );
294- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":hardcover_rating" )) safeParseDouble (content , builderMeta ::hardcoverRating );
295- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":hardcover_review_count" )) safeParseInt (content , builderMeta ::hardcoverReviewCount );
296- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":lubimyczytac_rating" )) safeParseDouble (content , builderMeta ::lubimyczytacRating );
297- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":ranobedb_rating" )) safeParseDouble (content , builderMeta ::ranobedbRating );
298- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":age_rating" )) safeParseInt (content , v -> { if (VALID_AGE_RATINGS .contains (v )) builderMeta .ageRating (v ); });
299- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":content_rating" )) builderMeta .contentRating (content );
300- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":moods" )) {
301- if (StringUtils .isNotBlank (content )) {
302- extractSetField (content , moods );
279+ switch (key ) {
280+ case BookLoreMetadata .NS_PREFIX + ":asin" -> builderMeta .asin (content );
281+ case BookLoreMetadata .NS_PREFIX + ":goodreads_id" -> builderMeta .goodreadsId (content );
282+ case BookLoreMetadata .NS_PREFIX + ":comicvine_id" -> builderMeta .comicvineId (content );
283+ case BookLoreMetadata .NS_PREFIX + ":ranobedb_id" -> builderMeta .ranobedbId (content );
284+ case BookLoreMetadata .NS_PREFIX + ":hardcover_id" -> builderMeta .hardcoverId (content );
285+ case BookLoreMetadata .NS_PREFIX + ":google_books_id" -> builderMeta .googleId (content );
286+ case BookLoreMetadata .NS_PREFIX + ":lubimyczytac_id" -> builderMeta .lubimyczytacId (content );
287+ case BookLoreMetadata .NS_PREFIX + ":page_count" ->
288+ safeParseInt (content , builderMeta ::pageCount );
289+ case BookLoreMetadata .NS_PREFIX + ":subtitle" -> builderMeta .subtitle (content );
290+ case BookLoreMetadata .NS_PREFIX + ":series_total" ->
291+ safeParseInt (content , builderMeta ::seriesTotal );
292+ case BookLoreMetadata .NS_PREFIX + ":rating" -> {
303293 }
304- }
305- else if (key .equals (BookLoreMetadata .NS_PREFIX + ":tags" )) {
306- if (StringUtils .isNotBlank (content )) {
307- extractSetField (content , tags );
294+ case BookLoreMetadata .NS_PREFIX + ":amazon_rating" ->
295+ safeParseDouble (content , builderMeta ::amazonRating );
296+ case BookLoreMetadata .NS_PREFIX + ":amazon_review_count" ->
297+ safeParseInt (content , builderMeta ::amazonReviewCount );
298+ case BookLoreMetadata .NS_PREFIX + ":goodreads_rating" ->
299+ safeParseDouble (content , builderMeta ::goodreadsRating );
300+ case BookLoreMetadata .NS_PREFIX + ":goodreads_review_count" ->
301+ safeParseInt (content , builderMeta ::goodreadsReviewCount );
302+ case BookLoreMetadata .NS_PREFIX + ":hardcover_rating" ->
303+ safeParseDouble (content , builderMeta ::hardcoverRating );
304+ case BookLoreMetadata .NS_PREFIX + ":hardcover_review_count" ->
305+ safeParseInt (content , builderMeta ::hardcoverReviewCount );
306+ case BookLoreMetadata .NS_PREFIX + ":lubimyczytac_rating" ->
307+ safeParseDouble (content , builderMeta ::lubimyczytacRating );
308+ case BookLoreMetadata .NS_PREFIX + ":ranobedb_rating" ->
309+ safeParseDouble (content , builderMeta ::ranobedbRating );
310+ case BookLoreMetadata .NS_PREFIX + ":age_rating" -> safeParseInt (content , v -> {
311+ if (VALID_AGE_RATINGS .contains (v )) builderMeta .ageRating (v );
312+ });
313+ case BookLoreMetadata .NS_PREFIX + ":content_rating" -> builderMeta .contentRating (content );
314+ case BookLoreMetadata .NS_PREFIX + ":moods" -> {
315+ if (StringUtils .isNotBlank (content )) {
316+ extractSetField (content , moods );
317+ }
318+ }
319+ case BookLoreMetadata .NS_PREFIX + ":tags" -> {
320+ if (StringUtils .isNotBlank (content )) {
321+ extractSetField (content , tags );
322+ }
308323 }
309324 }
310325 }
0 commit comments