From d94624e36a5339db44a9fa56fc2489824abd256c Mon Sep 17 00:00:00 2001 From: Jakub Izbicki Date: Mon, 22 Oct 2018 16:23:55 +0200 Subject: [PATCH] Fix review issues --- .../modifiers/resolution/ResolutionModifier.java | 10 +++++----- .../com/cognifide/aet/job/common/utils/Sampler.java | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java index 68327e5fd..cac6cbf02 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/modifiers/resolution/ResolutionModifier.java @@ -21,9 +21,8 @@ import com.cognifide.aet.job.api.exceptions.ParametersException; import com.cognifide.aet.job.api.exceptions.ProcessingException; import com.cognifide.aet.job.common.utils.Sampler; -import java.util.Arrays; -import java.util.LinkedList; import java.util.Map; +import java.util.Optional; import java.util.function.Supplier; import org.apache.commons.lang3.math.NumberUtils; import org.openqa.selenium.Dimension; @@ -57,7 +56,7 @@ public class ResolutionModifier implements CollectorJob { private static final int MAX_SAMPLES_THRESHOLD = 15; - public static final int SAMPLE_QUEUE_SIZE = 3; + private static final int SAMPLE_QUEUE_SIZE = 3; private final WebDriver webDriver; @@ -89,8 +88,9 @@ public void setParameters(Map params) throws ParametersException .checkRange(height, 1, MAX_SIZE, "Height should be greater than 0 and smaller than " + MAX_SIZE); } else { - samplingPeriod = params.containsKey(SAMPLING_PERIOD_PARAM) ? NumberUtils - .toInt(params.get(SAMPLING_PERIOD_PARAM)) : DEFAULT_SAMPLING_WAIT_PERIOD; + samplingPeriod = Optional.ofNullable(params.get(SAMPLING_PERIOD_PARAM)) + .map(NumberUtils::toInt) + .orElse(DEFAULT_SAMPLING_WAIT_PERIOD); } } else { throw new ParametersException("You have to specify width, height parameter is optional"); diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/utils/Sampler.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/utils/Sampler.java index 1a4e0ffe8..64ae574e4 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/utils/Sampler.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/utils/Sampler.java @@ -15,7 +15,6 @@ */ package com.cognifide.aet.job.common.utils; -import java.util.LinkedList; import java.util.function.Supplier; import org.apache.commons.collections.buffer.CircularFifoBuffer; import org.slf4j.Logger;