Skip to content

Commit

Permalink
Inline StringUtils methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Apr 4, 2023
1 parent db428b5 commit e6a7d2c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.maven.configuration;

import org.apache.maven.internal.StringUtils;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
Expand Down Expand Up @@ -88,7 +87,7 @@ public DefaultBeanConfigurationRequest setConfiguration(
Model model, String pluginGroupId, String pluginArtifactId, String pluginExecutionId) {
Plugin plugin = findPlugin(model, pluginGroupId, pluginArtifactId);
if (plugin != null) {
if (StringUtils.isNotEmpty(pluginExecutionId)) {
if (pluginExecutionId != null && !pluginExecutionId.isEmpty()) {
for (PluginExecution execution : plugin.getExecutions()) {
if (pluginExecutionId.equals(execution.getId())) {
setConfiguration(execution.getConfiguration());
Expand All @@ -103,8 +102,12 @@ public DefaultBeanConfigurationRequest setConfiguration(
}

private Plugin findPlugin(Model model, String groupId, String artifactId) {
StringUtils.notBlank(groupId, "groupId can neither be null, empty nor blank");
StringUtils.notBlank(artifactId, "artifactId can neither be null, empty nor blank");
if (!(groupId != null && !groupId.isEmpty())) {
throw new IllegalArgumentException("groupId can neither be null nor empty");
}
if (!(artifactId != null && !artifactId.isEmpty())) {
throw new IllegalArgumentException("artifactId can neither be null nor empty");
}

if (model != null) {
Build build = model.getBuild();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Properties;
import java.util.stream.Stream;

import org.apache.maven.internal.StringUtils;
import org.apache.maven.project.MavenProject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -109,10 +108,11 @@ private Properties loadResumptionFile(Path rootBuildDirectory) {

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.services.ArtifactCoordinateFactory;
import org.apache.maven.api.services.ArtifactCoordinateFactoryRequest;
import org.apache.maven.internal.StringUtils;
import org.eclipse.aether.artifact.ArtifactType;

import static org.apache.maven.internal.impl.Utils.cast;
Expand All @@ -43,10 +42,12 @@ public ArtifactCoordinate create(@Nonnull ArtifactCoordinateFactoryRequest reque
if (request.getType() != null) {
type = session.getSession().getArtifactTypeRegistry().get(request.getType());
}
String classifier = StringUtils.isNotEmpty(request.getClassifier())
String str1 = request.getClassifier();
String classifier = str1 != null && !str1.isEmpty()
? request.getClassifier()
: type != null ? type.getClassifier() : "";
String extension = StringUtils.isNotEmpty(request.getExtension())
String str = request.getExtension();
String extension = str != null && !str.isEmpty()
? request.getExtension()
: type != null ? type.getExtension() : "";
return new DefaultArtifactCoordinate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.services.ArtifactFactory;
import org.apache.maven.api.services.ArtifactFactoryRequest;
import org.apache.maven.internal.StringUtils;
import org.eclipse.aether.artifact.ArtifactType;

import static org.apache.maven.internal.impl.Utils.cast;
Expand All @@ -43,10 +42,12 @@ public Artifact create(@Nonnull ArtifactFactoryRequest request) {
if (request.getType() != null) {
type = session.getSession().getArtifactTypeRegistry().get(request.getType());
}
String classifier = StringUtils.isNotEmpty(request.getClassifier())
String str1 = request.getClassifier();
String classifier = str1 != null && !str1.isEmpty()
? request.getClassifier()
: type != null ? type.getClassifier() : null;
String extension = StringUtils.isNotEmpty(request.getExtension())
String str = request.getExtension();
String extension = str != null && !str.isEmpty()
? request.getExtension()
: type != null ? type.getExtension() : null;
return new DefaultArtifact(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.maven.internal.StringUtils;
import org.apache.maven.plugin.MavenPluginPrerequisitesChecker;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.eclipse.aether.version.InvalidVersionSpecificationException;
Expand All @@ -44,7 +43,7 @@ public MavenPluginJavaPrerequisiteChecker(final VersionScheme versionScheme) {
@Override
public void accept(PluginDescriptor pluginDescriptor) {
String requiredJavaVersion = pluginDescriptor.getRequiredJavaVersion();
if (StringUtils.isNotBlank(requiredJavaVersion)) {
if (requiredJavaVersion != null && !requiredJavaVersion.isEmpty()) {
String currentJavaVersion = System.getProperty("java.version");
if (!matchesVersion(requiredJavaVersion, currentJavaVersion)) {
throw new IllegalStateException("Required Java version " + requiredJavaVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.InputStream;
import java.util.Properties;

import org.apache.maven.internal.StringUtils;
import org.apache.maven.rtinfo.RuntimeInformation;
import org.eclipse.aether.version.InvalidVersionSpecificationException;
import org.eclipse.aether.version.Version;
Expand Down Expand Up @@ -89,7 +88,9 @@ private String loadMavenVersion() {

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

VersionConstraint constraint;
try {
Expand All @@ -101,7 +102,9 @@ public boolean isMavenVersion(String versionRange) {
Version current;
try {
String mavenVersion = getMavenVersion();
StringUtils.notBlank(mavenVersion, "Could not determine current Maven version");
if (!(mavenVersion != null && !mavenVersion.isEmpty())) {
throw new IllegalArgumentException("Could not determine current Maven version");
}

current = versionScheme.parseVersion(mavenVersion);
} catch (InvalidVersionSpecificationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.Locale;
import java.util.Properties;

import org.apache.maven.internal.StringUtils;
import org.codehaus.plexus.util.Os;
import org.slf4j.Logger;

Expand Down Expand Up @@ -106,7 +105,7 @@ static String createMavenVersionString(Properties buildProperties) {
if (rev != null || timestamp != null) {
msg += " (";
msg += (rev != null ? rev : "");
if (StringUtils.isNotBlank(timestamp)) {
if (timestamp != null && !timestamp.isEmpty()) {
String ts = formatTimestamp(Long.parseLong(timestamp));
msg += (rev != null ? "; " : "") + ts;
}
Expand Down

0 comments on commit e6a7d2c

Please sign in to comment.