diff --git a/bundles/org.pitest.pitclipse.launch/src/org/pitest/pitclipse/launch/config/LaunchConfigurationWrapper.java b/bundles/org.pitest.pitclipse.launch/src/org/pitest/pitclipse/launch/config/LaunchConfigurationWrapper.java index b500b8a7..403bb405 100644 --- a/bundles/org.pitest.pitclipse.launch/src/org/pitest/pitclipse/launch/config/LaunchConfigurationWrapper.java +++ b/bundles/org.pitest.pitclipse.launch/src/org/pitest/pitclipse/launch/config/LaunchConfigurationWrapper.java @@ -26,9 +26,7 @@ import java.io.File; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -46,6 +44,7 @@ import org.pitest.pitclipse.runner.PitOptions; import org.pitest.pitclipse.runner.PitOptions.PitOptionsBuilder; import org.pitest.pitclipse.runner.config.PitConfiguration; +import org.pitest.pitclipse.runner.util.PitUtils; public class LaunchConfigurationWrapper { @@ -214,7 +213,7 @@ private List getExcludedMethods() throws CoreException { } else { excludedMethods = pitConfiguration.getExcludedMethods(); } - return splitBasedOnComma(excludedMethods); + return PitUtils.splitBasedOnComma(excludedMethods); } private List getAvoidCallsTo() throws CoreException { @@ -224,7 +223,7 @@ private List getAvoidCallsTo() throws CoreException { } else { avoidCallsTo = pitConfiguration.getAvoidCallsTo(); } - return splitBasedOnComma(avoidCallsTo); + return PitUtils.splitBasedOnComma(avoidCallsTo); } private List getExcludedClasses() throws CoreException { @@ -234,14 +233,7 @@ private List getExcludedClasses() throws CoreException { } else { excludedClasses = pitConfiguration.getExcludedClasses(); } - return splitBasedOnComma(excludedClasses); - } - - private List splitBasedOnComma(String elements) { - return Arrays.stream(elements.split(",")) - .map(String::trim) - .filter(s -> !s.isEmpty()) - .collect(Collectors.toList()); + return PitUtils.splitBasedOnComma(excludedClasses); } private boolean isIncrementalAnalysis() throws CoreException { @@ -268,7 +260,7 @@ private List getClassesFromProject() throws CoreException { private List getTargetClasses() throws CoreException { final String targetClasses = launchConfig.getAttribute(ATTR_TARGET_CLASSES, ""); return targetClasses.equals("") ? null - : new ArrayList<>(splitBasedOnComma(targetClasses)); + : new ArrayList<>(PitUtils.splitBasedOnComma(targetClasses)); } public IResource[] getMappedResources() throws CoreException { diff --git a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/util/PitUtils.java b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/util/PitUtils.java new file mode 100644 index 00000000..c4b6d5cc --- /dev/null +++ b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/util/PitUtils.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright 2021 Lorenzo Bettini and contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + ******************************************************************************/ +package org.pitest.pitclipse.runner.util; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author Lorenzo Bettini + * + */ +public class PitUtils { + + private PitUtils() { + // only static methods + } + + public static List splitBasedOnComma(String elements) { + return Arrays.stream(elements.split(",")) + .map(String::trim) + .filter(s -> !s.isEmpty()) + .collect(Collectors.toList()); + } +}