Skip to content

Commit d14c037

Browse files
committed
Inline StringUtils methods
1 parent db428b5 commit d14c037

File tree

8 files changed

+30
-76
lines changed

8 files changed

+30
-76
lines changed

maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.apache.maven.configuration;
2020

21-
import org.apache.maven.internal.StringUtils;
2221
import org.apache.maven.model.Build;
2322
import org.apache.maven.model.Model;
2423
import org.apache.maven.model.Plugin;
@@ -88,7 +87,7 @@ public DefaultBeanConfigurationRequest setConfiguration(
8887
Model model, String pluginGroupId, String pluginArtifactId, String pluginExecutionId) {
8988
Plugin plugin = findPlugin(model, pluginGroupId, pluginArtifactId);
9089
if (plugin != null) {
91-
if (StringUtils.isNotEmpty(pluginExecutionId)) {
90+
if (pluginExecutionId != null && !pluginExecutionId.isEmpty()) {
9291
for (PluginExecution execution : plugin.getExecutions()) {
9392
if (pluginExecutionId.equals(execution.getId())) {
9493
setConfiguration(execution.getConfiguration());
@@ -103,8 +102,12 @@ public DefaultBeanConfigurationRequest setConfiguration(
103102
}
104103

105104
private Plugin findPlugin(Model model, String groupId, String artifactId) {
106-
StringUtils.notBlank(groupId, "groupId can neither be null, empty nor blank");
107-
StringUtils.notBlank(artifactId, "artifactId can neither be null, empty nor blank");
105+
if (!(groupId != null && !groupId.isEmpty())) {
106+
throw new IllegalArgumentException("groupId can neither be null nor empty");
107+
}
108+
if (!(artifactId != null && !artifactId.isEmpty())) {
109+
throw new IllegalArgumentException("artifactId can neither be null nor empty");
110+
}
108111

109112
if (model != null) {
110113
Build build = model.getBuild();

maven-core/src/main/java/org/apache/maven/execution/DefaultBuildResumptionDataRepository.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.Properties;
3131
import java.util.stream.Stream;
3232

33-
import org.apache.maven.internal.StringUtils;
3433
import org.apache.maven.project.MavenProject;
3534
import org.slf4j.Logger;
3635
import org.slf4j.LoggerFactory;
@@ -109,10 +108,11 @@ private Properties loadResumptionFile(Path rootBuildDirectory) {
109108

110109
// This method is made package-private for testing purposes
111110
void applyResumptionProperties(MavenExecutionRequest request, Properties properties) {
112-
if (properties.containsKey(REMAINING_PROJECTS) && StringUtils.isEmpty(request.getResumeFrom())) {
111+
String str1 = request.getResumeFrom();
112+
if (properties.containsKey(REMAINING_PROJECTS) && !(str1 != null && !str1.isEmpty())) {
113113
String propertyValue = properties.getProperty(REMAINING_PROJECTS);
114114
Stream.of(propertyValue.split(PROPERTY_DELIMITER))
115-
.filter(StringUtils::isNotEmpty)
115+
.filter(str -> str != null && !str.isEmpty())
116116
.forEach(request.getProjectActivation()::activateOptionalProject);
117117
LOGGER.info("Resuming from {} due to the --resume / -r feature.", propertyValue);
118118
}

maven-core/src/main/java/org/apache/maven/internal/StringUtils.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactCoordinateFactory.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.maven.api.annotations.Nonnull;
2626
import org.apache.maven.api.services.ArtifactCoordinateFactory;
2727
import org.apache.maven.api.services.ArtifactCoordinateFactoryRequest;
28-
import org.apache.maven.internal.StringUtils;
2928
import org.eclipse.aether.artifact.ArtifactType;
3029

3130
import static org.apache.maven.internal.impl.Utils.cast;
@@ -43,12 +42,12 @@ public ArtifactCoordinate create(@Nonnull ArtifactCoordinateFactoryRequest reque
4342
if (request.getType() != null) {
4443
type = session.getSession().getArtifactTypeRegistry().get(request.getType());
4544
}
46-
String classifier = StringUtils.isNotEmpty(request.getClassifier())
47-
? request.getClassifier()
48-
: type != null ? type.getClassifier() : "";
49-
String extension = StringUtils.isNotEmpty(request.getExtension())
50-
? request.getExtension()
51-
: type != null ? type.getExtension() : "";
45+
String str1 = request.getClassifier();
46+
String classifier =
47+
str1 != null && !str1.isEmpty() ? request.getClassifier() : type != null ? type.getClassifier() : "";
48+
String str = request.getExtension();
49+
String extension =
50+
str != null && !str.isEmpty() ? request.getExtension() : type != null ? type.getExtension() : "";
5251
return new DefaultArtifactCoordinate(
5352
session,
5453
new org.eclipse.aether.artifact.DefaultArtifact(

maven-core/src/main/java/org/apache/maven/internal/impl/DefaultArtifactFactory.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.maven.api.annotations.Nonnull;
2626
import org.apache.maven.api.services.ArtifactFactory;
2727
import org.apache.maven.api.services.ArtifactFactoryRequest;
28-
import org.apache.maven.internal.StringUtils;
2928
import org.eclipse.aether.artifact.ArtifactType;
3029

3130
import static org.apache.maven.internal.impl.Utils.cast;
@@ -43,12 +42,12 @@ public Artifact create(@Nonnull ArtifactFactoryRequest request) {
4342
if (request.getType() != null) {
4443
type = session.getSession().getArtifactTypeRegistry().get(request.getType());
4544
}
46-
String classifier = StringUtils.isNotEmpty(request.getClassifier())
47-
? request.getClassifier()
48-
: type != null ? type.getClassifier() : null;
49-
String extension = StringUtils.isNotEmpty(request.getExtension())
50-
? request.getExtension()
51-
: type != null ? type.getExtension() : null;
45+
String str1 = request.getClassifier();
46+
String classifier =
47+
str1 != null && !str1.isEmpty() ? request.getClassifier() : type != null ? type.getClassifier() : null;
48+
String str = request.getExtension();
49+
String extension =
50+
str != null && !str.isEmpty() ? request.getExtension() : type != null ? type.getExtension() : null;
5251
return new DefaultArtifact(
5352
session,
5453
new org.eclipse.aether.artifact.DefaultArtifact(

maven-core/src/main/java/org/apache/maven/plugin/internal/MavenPluginJavaPrerequisiteChecker.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import javax.inject.Named;
2323
import javax.inject.Singleton;
2424

25-
import org.apache.maven.internal.StringUtils;
2625
import org.apache.maven.plugin.MavenPluginPrerequisitesChecker;
2726
import org.apache.maven.plugin.descriptor.PluginDescriptor;
2827
import org.eclipse.aether.version.InvalidVersionSpecificationException;
@@ -44,7 +43,7 @@ public MavenPluginJavaPrerequisiteChecker(final VersionScheme versionScheme) {
4443
@Override
4544
public void accept(PluginDescriptor pluginDescriptor) {
4645
String requiredJavaVersion = pluginDescriptor.getRequiredJavaVersion();
47-
if (StringUtils.isNotBlank(requiredJavaVersion)) {
46+
if (requiredJavaVersion != null && !requiredJavaVersion.isEmpty()) {
4847
String currentJavaVersion = System.getProperty("java.version");
4948
if (!matchesVersion(requiredJavaVersion, currentJavaVersion)) {
5049
throw new IllegalStateException("Required Java version " + requiredJavaVersion

maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.io.InputStream;
2727
import java.util.Properties;
2828

29-
import org.apache.maven.internal.StringUtils;
3029
import org.apache.maven.rtinfo.RuntimeInformation;
3130
import org.eclipse.aether.version.InvalidVersionSpecificationException;
3231
import org.eclipse.aether.version.Version;
@@ -89,7 +88,9 @@ private String loadMavenVersion() {
8988

9089
@Override
9190
public boolean isMavenVersion(String versionRange) {
92-
StringUtils.notBlank(versionRange, "versionRange can neither be null, empty nor blank");
91+
if (!(versionRange != null && !versionRange.isEmpty())) {
92+
throw new IllegalArgumentException("versionRange can neither be null nor empty");
93+
}
9394

9495
VersionConstraint constraint;
9596
try {
@@ -101,7 +102,9 @@ public boolean isMavenVersion(String versionRange) {
101102
Version current;
102103
try {
103104
String mavenVersion = getMavenVersion();
104-
StringUtils.notBlank(mavenVersion, "Could not determine current Maven version");
105+
if (!(mavenVersion != null && !mavenVersion.isEmpty())) {
106+
throw new IllegalArgumentException("Could not determine current Maven version");
107+
}
105108

106109
current = versionScheme.parseVersion(mavenVersion);
107110
} catch (InvalidVersionSpecificationException e) {

maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Locale;
2626
import java.util.Properties;
2727

28-
import org.apache.maven.internal.StringUtils;
2928
import org.codehaus.plexus.util.Os;
3029
import org.slf4j.Logger;
3130

@@ -106,7 +105,7 @@ static String createMavenVersionString(Properties buildProperties) {
106105
if (rev != null || timestamp != null) {
107106
msg += " (";
108107
msg += (rev != null ? rev : "");
109-
if (StringUtils.isNotBlank(timestamp)) {
108+
if (timestamp != null && !timestamp.isEmpty()) {
110109
String ts = formatTimestamp(Long.parseLong(timestamp));
111110
msg += (rev != null ? "; " : "") + ts;
112111
}

0 commit comments

Comments
 (0)