Skip to content

Commit ebc2acf

Browse files
committed
refactor(JsoupSiteParser): extract method getFirstElement().
No functional changes.
1 parent 9accb68 commit ebc2acf

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/main/java/ru/mystamps/web/feature/series/importing/extractor/JsoupSiteParser.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,7 @@ protected String extractCountry(Element body) {
232232
}
233233

234234
protected String extractImageUrl(Element body) {
235-
if (imageUrlLocator == null) {
236-
return null;
237-
}
238-
239-
Element elem = body.selectFirst(imageUrlLocator);
235+
Element elem = getFirstElement(body, imageUrlLocator);
240236
if (elem == null) {
241237
return null;
242238
}
@@ -302,11 +298,7 @@ protected String extractSellerName(Element body) {
302298
}
303299

304300
protected String extractSellerUrl(Element body) {
305-
if (sellerLocator == null) {
306-
return null;
307-
}
308-
309-
Element elem = body.selectFirst(sellerLocator);
301+
Element elem = getFirstElement(body, sellerLocator);
310302
if (elem == null) {
311303
return null;
312304
}
@@ -335,12 +327,16 @@ protected String extractCurrency(Element body) {
335327
return currencyValue;
336328
}
337329

338-
private static String getTextOfTheFirstElement(Element body, String locator) {
330+
private static Element getFirstElement(Element body, String locator) {
339331
if (locator == null) {
340332
return null;
341333
}
342334

343-
Element elem = body.selectFirst(locator);
335+
return body.selectFirst(locator);
336+
}
337+
338+
private static String getTextOfTheFirstElement(Element body, String locator) {
339+
Element elem = getFirstElement(body, locator);
344340
if (elem == null) {
345341
return null;
346342
}

0 commit comments

Comments
 (0)