Skip to content

Commit 12b1c2c

Browse files
authored
Automatic code change (#349)
Some archaic constructs were replaced with more appropriate methods around string handling. This PR does not introduce any semantic change.
1 parent 7907f20 commit 12b1c2c

File tree

31 files changed

+47
-47
lines changed

31 files changed

+47
-47
lines changed

maven-resolver-api/src/main/java/org/eclipse/aether/artifact/AbstractArtifact.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public String toString() {
134134
buffer.append(getGroupId());
135135
buffer.append(':').append(getArtifactId());
136136
buffer.append(':').append(getExtension());
137-
if (getClassifier().length() > 0) {
137+
if (!getClassifier().isEmpty()) {
138138
buffer.append(':').append(getClassifier());
139139
}
140140
buffer.append(':').append(getVersion());

maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifactType.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ public DefaultArtifactType(
8585
boolean constitutesBuildPath,
8686
boolean includesDependencies) {
8787
this.id = requireNonNull(id, "type id cannot be null");
88-
if (id.length() == 0) {
88+
if (id.isEmpty()) {
8989
throw new IllegalArgumentException("type id cannot be empty");
9090
}
9191
this.extension = emptify(extension);
9292
this.classifier = emptify(classifier);
9393
Map<String, String> props = new HashMap<>();
9494
props.put(ArtifactProperties.TYPE, id);
95-
props.put(ArtifactProperties.LANGUAGE, (language != null && language.length() > 0) ? language : "none");
95+
props.put(ArtifactProperties.LANGUAGE, (language != null && !language.isEmpty()) ? language : "none");
9696
props.put(ArtifactProperties.INCLUDES_DEPENDENCIES, Boolean.toString(includesDependencies));
9797
props.put(ArtifactProperties.CONSTITUTES_BUILD_PATH, Boolean.toString(constitutesBuildPath));
9898
properties = Collections.unmodifiableMap(props);
@@ -108,7 +108,7 @@ public DefaultArtifactType(
108108
*/
109109
public DefaultArtifactType(String id, String extension, String classifier, Map<String, String> properties) {
110110
this.id = requireNonNull(id, "type id cannot be null");
111-
if (id.length() == 0) {
111+
if (id.isEmpty()) {
112112
throw new IllegalArgumentException("type id cannot be empty");
113113
}
114114
this.extension = emptify(extension);

maven-resolver-api/src/main/java/org/eclipse/aether/collection/UnsolvableVersionConflictException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private static String toPath(List<? extends DependencyNode> path) {
8989
buffer.append(artifact.getGroupId());
9090
buffer.append(':').append(artifact.getArtifactId());
9191
buffer.append(':').append(artifact.getExtension());
92-
if (artifact.getClassifier().length() > 0) {
92+
if (!artifact.getClassifier().isEmpty()) {
9393
buffer.append(':').append(artifact.getClassifier());
9494
}
9595
buffer.append(':').append(node.getVersionConstraint());

maven-resolver-api/src/main/java/org/eclipse/aether/graph/Exclusion.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public String toString() {
9191
+ getArtifactId()
9292
+ ':'
9393
+ getExtension()
94-
+ (getClassifier().length() > 0 ? ':' + getClassifier() : "");
94+
+ (!getClassifier().isEmpty() ? ':' + getClassifier() : "");
9595
}
9696

9797
@Override

maven-resolver-api/src/main/java/org/eclipse/aether/metadata/AbstractMetadata.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ protected static Map<String, String> copyProperties(Map<String, String> properti
7373
@Override
7474
public String toString() {
7575
StringBuilder buffer = new StringBuilder(128);
76-
if (getGroupId().length() > 0) {
76+
if (!getGroupId().isEmpty()) {
7777
buffer.append(getGroupId());
7878
}
79-
if (getArtifactId().length() > 0) {
79+
if (!getArtifactId().isEmpty()) {
8080
buffer.append(':').append(getArtifactId());
8181
}
82-
if (getVersion().length() > 0) {
82+
if (!getVersion().isEmpty()) {
8383
buffer.append(':').append(getVersion());
8484
}
8585
buffer.append('/').append(getType());

maven-resolver-api/src/main/java/org/eclipse/aether/repository/AuthenticationContext.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public <T> T get(String key, Class<T> type) {
242242
*/
243243
public <T> T get(String key, Map<String, String> data, Class<T> type) {
244244
requireNonNull(key, "authentication key cannot be null");
245-
if (key.length() == 0) {
245+
if (key.isEmpty()) {
246246
throw new IllegalArgumentException("authentication key cannot be empty");
247247
}
248248

@@ -304,7 +304,7 @@ private <T> T convert(Object value, Class<T> type) {
304304
*/
305305
public void put(String key, Object value) {
306306
requireNonNull(key, "authentication key cannot be null");
307-
if (key.length() == 0) {
307+
if (key.isEmpty()) {
308308
throw new IllegalArgumentException("authentication key cannot be empty");
309309
}
310310

maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultLocalPathComposer.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public String getPathForArtifact(Artifact artifact, boolean local) {
5353
path.append(artifact.getVersion());
5454
}
5555

56-
if (artifact.getClassifier().length() > 0) {
56+
if (!artifact.getClassifier().isEmpty()) {
5757
path.append('-').append(artifact.getClassifier());
5858
}
5959

60-
if (artifact.getExtension().length() > 0) {
60+
if (!artifact.getExtension().isEmpty()) {
6161
path.append('.').append(artifact.getExtension());
6262
}
6363

@@ -71,13 +71,13 @@ public String getPathForMetadata(Metadata metadata, String repositoryKey) {
7171

7272
StringBuilder path = new StringBuilder(128);
7373

74-
if (metadata.getGroupId().length() > 0) {
74+
if (!metadata.getGroupId().isEmpty()) {
7575
path.append(metadata.getGroupId().replace('.', '/')).append('/');
7676

77-
if (metadata.getArtifactId().length() > 0) {
77+
if (!metadata.getArtifactId().isEmpty()) {
7878
path.append(metadata.getArtifactId()).append('/');
7979

80-
if (metadata.getVersion().length() > 0) {
80+
if (!metadata.getVersion().isEmpty()) {
8181
path.append(metadata.getVersion()).append('/');
8282
}
8383
}

maven-resolver-spi/src/main/java/org/eclipse/aether/spi/connector/transport/GetTask.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public GetTask setChecksum(String algorithm, String value) {
223223
if (checksums.isEmpty()) {
224224
checksums = new HashMap<>();
225225
}
226-
if (value != null && value.length() > 0) {
226+
if (value != null && !value.isEmpty()) {
227227
checksums.put(algorithm, value);
228228
} else {
229229
checksums.remove(algorithm);

maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/DependencyGraphParser.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private boolean isEOFMarker(String line) {
265265
}
266266

267267
private static boolean isEmpty(String line) {
268-
return line == null || line.length() == 0;
268+
return line == null || line.isEmpty();
269269
}
270270

271271
private static String cutComment(String line) {

maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/IniArtifactDataReader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private Artifact relocation(List<String> list) {
222222
}
223223

224224
private static boolean isEmpty(String line) {
225-
return line == null || line.length() == 0;
225+
return line == null || line.isEmpty();
226226
}
227227

228228
private static String cutComment(String line) {

maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/NodeBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ public NodeBuilder properties(Map<String, String> properties) {
122122

123123
public DependencyNode build() {
124124
Dependency dependency = null;
125-
if (artifactId != null && artifactId.length() > 0) {
125+
if (artifactId != null && !artifactId.isEmpty()) {
126126
Artifact artifact =
127127
new DefaultArtifact(groupId, artifactId, classifier, ext, version, properties, (File) null);
128128
dependency = new Dependency(artifact, scope, optional);
129129
}
130130
DefaultDependencyNode node = new DefaultDependencyNode(dependency);
131-
if (artifactId != null && artifactId.length() > 0) {
131+
if (artifactId != null && !artifactId.isEmpty()) {
132132
try {
133133
node.setVersion(versionScheme.parseVersion(version));
134134
node.setVersionConstraint(versionScheme.parseVersionConstraint(range != null ? range : version));

maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionRange.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ final class TestVersionRange implements VersionRange {
8686
range, "Invalid version range " + range + ", bounds may not contain additional ','");
8787
}
8888

89-
lowerBound = parsedLowerBound.length() > 0 ? new TestVersion(parsedLowerBound) : null;
90-
upperBound = parsedUpperBound.length() > 0 ? new TestVersion(parsedUpperBound) : null;
89+
lowerBound = !parsedLowerBound.isEmpty() ? new TestVersion(parsedLowerBound) : null;
90+
upperBound = !parsedUpperBound.isEmpty() ? new TestVersion(parsedUpperBound) : null;
9191

9292
if (upperBound != null && lowerBound != null) {
9393
if (upperBound.compareTo(lowerBound) < 0) {

maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestVersionScheme.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ public VersionConstraint parseVersionConstraint(final String constraint)
6969

7070
process = process.substring(index + 1).trim();
7171

72-
if (process.length() > 0 && process.startsWith(",")) {
72+
if (process.startsWith(",")) {
7373
process = process.substring(1).trim();
7474
}
7575
}
7676

77-
if (process.length() > 0 && !ranges.isEmpty()) {
77+
if (!process.isEmpty() && !ranges.isEmpty()) {
7878
throw new InvalidVersionSpecificationException(
7979
constraint, "Invalid version range " + constraint + ", expected [ or ( but got " + process);
8080
}

maven-resolver-transport-classpath/src/main/java/org/eclipse/aether/transport/classpath/ClasspathTransporter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ final class ClasspathTransporter extends AbstractTransporter {
6161
} else {
6262
base = ssp;
6363
}
64-
if (base.length() > 0 && !base.endsWith("/")) {
64+
if (!base.isEmpty() && !base.endsWith("/")) {
6565
base += '/';
6666
}
6767
} catch (URISyntaxException e) {

maven-resolver-transport-file/src/main/java/org/eclipse/aether/transport/file/PathUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static String basedir(String url) {
5252

5353
String retValue = null;
5454

55-
if (protocol.length() > 0) {
55+
if (!protocol.isEmpty()) {
5656
retValue = url.substring(protocol.length() + 1);
5757
} else {
5858
retValue = url;

maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/UriUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class UriUtils {
3232

3333
public static URI resolve(URI base, URI ref) {
3434
String path = ref.getRawPath();
35-
if (path != null && path.length() > 0) {
35+
if (path != null && !path.isEmpty()) {
3636
path = base.getRawPath();
3737
if (path == null || !path.endsWith("/")) {
3838
try {

maven-resolver-util/src/main/java/org/eclipse/aether/util/ChecksumUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static String read(File checksumFile) throws IOException {
6060
break;
6161
}
6262
line = line.trim();
63-
if (line.length() > 0) {
63+
if (!line.isEmpty()) {
6464
checksum = line;
6565
break;
6666
}

maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private static StringBuilder concat(String groupId, String artifactId, String ex
133133
if (extension != null) {
134134
buffer.append(extension);
135135
}
136-
if (classifier != null && classifier.length() > 0) {
136+
if (classifier != null && !classifier.isEmpty()) {
137137
buffer.append(SEP).append(classifier);
138138
}
139139

maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/WorkerThreadFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public final class WorkerThreadFactory implements ThreadFactory {
4444
public WorkerThreadFactory(String namePrefix) {
4545
this.factory = Executors.defaultThreadFactory();
4646
this.namePrefix =
47-
((namePrefix != null && namePrefix.length() > 0) ? namePrefix : getCallerSimpleClassName() + '-')
47+
((namePrefix != null && !namePrefix.isEmpty()) ? namePrefix : getCallerSimpleClassName() + '-')
4848
+ POOL_INDEX.getAndIncrement()
4949
+ '-';
5050
threadIndex = new AtomicInteger();

maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/AbstractPatternDependencyFilter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private boolean matches(final String token, final String pattern) {
128128
boolean matches;
129129

130130
// support full wildcard and implied wildcard
131-
if ("*".equals(pattern) || pattern.length() == 0) {
131+
if ("*".equals(pattern) || pattern.isEmpty()) {
132132
matches = true;
133133
}
134134
// support contains wildcard

maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/DependencyFilterUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public static DependencyFilter classpathFilter(Collection<String> classpathTypes
133133
String[] tokens = classpathType.split("[+,]");
134134
for (String token : tokens) {
135135
token = token.trim();
136-
if (token.length() > 0) {
136+
if (!token.isEmpty()) {
137137
types.add(token);
138138
}
139139
}

maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/ClassicDependencyManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ public DependencyManager deriveChildManager(DependencyCollectionContext context)
102102
Object key = getKey(artifact);
103103

104104
String version = artifact.getVersion();
105-
if (version.length() > 0 && !managedVersions.containsKey(key)) {
105+
if (!version.isEmpty() && !managedVersions.containsKey(key)) {
106106
if (managedVersions == this.managedVersions) {
107107
managedVersions = new HashMap<>(this.managedVersions);
108108
}
109109
managedVersions.put(key, version);
110110
}
111111

112112
String scope = managedDependency.getScope();
113-
if (scope.length() > 0 && !managedScopes.containsKey(key)) {
113+
if (!scope.isEmpty() && !managedScopes.containsKey(key)) {
114114
if (managedScopes == this.managedScopes) {
115115
managedScopes = new HashMap<>(this.managedScopes);
116116
}

maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/DefaultDependencyManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ public DependencyManager deriveChildManager(final DependencyCollectionContext co
100100
Object key = getKey(artifact);
101101

102102
String version = artifact.getVersion();
103-
if (version.length() > 0 && !versions.containsKey(key)) {
103+
if (!version.isEmpty() && !versions.containsKey(key)) {
104104
if (versions == this.managedVersions) {
105105
versions = new HashMap<>(this.managedVersions);
106106
}
107107
versions.put(key, version);
108108
}
109109

110110
String scope = managedDependency.getScope();
111-
if (scope.length() > 0 && !scopes.containsKey(key)) {
111+
if (!scope.isEmpty() && !scopes.containsKey(key)) {
112112
if (scopes == this.managedScopes) {
113113
scopes = new HashMap<>(this.managedScopes);
114114
}

maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/TransitiveDependencyManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ public DependencyManager deriveChildManager(final DependencyCollectionContext co
100100
Object key = getKey(artifact);
101101

102102
String version = artifact.getVersion();
103-
if (version.length() > 0 && !versions.containsKey(key)) {
103+
if (!version.isEmpty() && !versions.containsKey(key)) {
104104
if (versions == managedVersions) {
105105
versions = new HashMap<>(managedVersions);
106106
}
107107
versions.put(key, version);
108108
}
109109

110110
String scope = managedDependency.getScope();
111-
if (scope.length() > 0 && !scopes.containsKey(key)) {
111+
if (!scope.isEmpty() && !scopes.containsKey(key)) {
112112
if (scopes == this.managedScopes) {
113113
scopes = new HashMap<>(this.managedScopes);
114114
}

maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/ComponentAuthentication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class ComponentAuthentication implements Authentication {
3838

3939
ComponentAuthentication(String key, Object value) {
4040
this.key = requireNonNull(key, "authentication key cannot be null");
41-
if (key.length() == 0) {
41+
if (key.isEmpty()) {
4242
throw new IllegalArgumentException("authentication key cannot be empty");
4343
}
4444
this.value = value;

maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public RemoteRepository getMirror(RemoteRepository repository) {
8585

8686
builder.setBlocked(mirror.blocked);
8787

88-
if (mirror.type != null && mirror.type.length() > 0) {
88+
if (mirror.type != null && !mirror.type.isEmpty()) {
8989
builder.setContentType(mirror.type);
9090
}
9191

maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/SecretAuthentication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ final class SecretAuthentication implements Authentication {
6060

6161
private SecretAuthentication(char[] value, String key) {
6262
this.key = requireNonNull(key, "authentication key cannot be null");
63-
if (key.length() == 0) {
63+
if (key.isEmpty()) {
6464
throw new IllegalArgumentException("authentication key cannot be empty");
6565
}
6666
this.secretHash = Arrays.hashCode(value) ^ KEYS[0].hashCode();

maven-resolver-util/src/main/java/org/eclipse/aether/util/repository/StringAuthentication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class StringAuthentication implements Authentication {
3838

3939
StringAuthentication(String key, String value) {
4040
this.key = requireNonNull(key, "authentication key cannot be null");
41-
if (key.length() == 0) {
41+
if (key.isEmpty()) {
4242
throw new IllegalArgumentException("authentication key cannot be empty");
4343
}
4444
this.value = value;

maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersion.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static final class Tokenizer {
206206
private boolean terminatedByNumber;
207207

208208
Tokenizer(String version) {
209-
this.version = (version.length() > 0) ? version : "0";
209+
this.version = (!version.isEmpty()) ? version : "0";
210210
this.versionLength = this.version.length();
211211
}
212212

maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionRange.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ final class GenericVersionRange implements VersionRange {
9494
range, "Invalid version range " + range + ", bounds may not contain additional ','");
9595
}
9696

97-
lowerBound = parsedLowerBound.length() > 0 ? parse(parsedLowerBound) : null;
98-
upperBound = parsedUpperBound.length() > 0 ? parse(parsedUpperBound) : null;
97+
lowerBound = !parsedLowerBound.isEmpty() ? parse(parsedLowerBound) : null;
98+
upperBound = !parsedUpperBound.isEmpty() ? parse(parsedUpperBound) : null;
9999

100100
if (upperBound != null && lowerBound != null) {
101101
if (upperBound.compareTo(lowerBound) < 0) {

maven-resolver-util/src/main/java/org/eclipse/aether/util/version/GenericVersionScheme.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public GenericVersionConstraint parseVersionConstraint(final String constraint)
9898
}
9999
}
100100

101-
if (process.length() > 0 && !ranges.isEmpty()) {
101+
if (!process.isEmpty() && !ranges.isEmpty()) {
102102
throw new InvalidVersionSpecificationException(
103103
constraint, "Invalid version range " + constraint + ", expected [ or ( but got " + process);
104104
}

0 commit comments

Comments
 (0)