Polish "Wrap ternary operator within parentheses"

See gh-31076
This commit is contained in:
Stephane Nicoll
2023-08-22 15:36:30 +02:00
parent 6712c044b1
commit 2b76c4d847
36 changed files with 62 additions and 61 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@ public class StringUtilsBenchmark {
}
private String createSamplePath(Random random) {
String separator = random.nextBoolean() ? "/" : "\\";
String separator = (random.nextBoolean() ? "/" : "\\");
StringBuilder sb = new StringBuilder();
sb.append("jar:file:///c:");
for (int i = 0; i < this.segmentCount; i++) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,7 +90,7 @@ public final class GeneratedClass {
private String generateSequencedMethodName(MethodName name) {
int sequence = this.methodNameSequenceGenerator
.computeIfAbsent(name, key -> new AtomicInteger()).getAndIncrement();
return (sequence > 0) ? name.toString() + sequence : name.toString();
return (sequence > 0 ? name.toString() + sequence : name.toString());
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,7 +86,7 @@ public class InMemoryGeneratedFiles implements GeneratedFiles {
Assert.notNull(kind, "'kind' must not be null");
Assert.hasLength(path, "'path' must not be empty");
Map<String, InputStreamSource> paths = this.files.get(kind);
return (paths != null) ? paths.get(path) : null;
return (paths != null ? paths.get(path) : null);
}
}

View File

@@ -116,7 +116,7 @@ final class MethodName {
StringBuilder name = new StringBuilder(chars.length);
boolean uppercase = false;
for (char ch : chars) {
char outputChar = (!uppercase) ? ch : Character.toUpperCase(ch);
char outputChar = (!uppercase ? ch : Character.toUpperCase(ch));
name.append((!Character.isLetter(ch)) ? "" : outputChar);
uppercase = (ch == '.');
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,7 +80,7 @@ public class ResourceHints {
*/
public ResourceHints registerPatternIfPresent(@Nullable ClassLoader classLoader, String location,
Consumer<ResourcePatternHints.Builder> resourceHint) {
ClassLoader classLoaderToUse = (classLoader != null) ? classLoader : getClass().getClassLoader();
ClassLoader classLoaderToUse = (classLoader != null ? classLoader : getClass().getClassLoader());
if (classLoaderToUse.getResource(location) != null) {
registerPattern(resourceHint);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,7 +73,7 @@ final class SimpleTypeReference extends AbstractTypeReference {
return new SimpleTypeReference(className.substring(0, i), className.substring(i + 1), null);
}
else {
String packageName = isPrimitive(className) ? "java.lang" : "";
String packageName = (isPrimitive(className) ? "java.lang" : "");
return new SimpleTypeReference(packageName, className, null);
}
}
@@ -101,7 +101,7 @@ final class SimpleTypeReference extends AbstractTypeReference {
if (type == null) {
return;
}
String typeName = (type.getEnclosingType() != null) ? "." + type.getSimpleName() : type.getSimpleName();
String typeName = (type.getEnclosingType() != null ? "." + type.getSimpleName() : type.getSimpleName());
sb.insert(0, typeName);
buildName(type.getEnclosingType(), sb);
}

View File

@@ -73,7 +73,7 @@ public class FilePatternResourceHintsRegistrar {
@Deprecated(since = "6.0.12", forRemoval = true)
public void registerHints(ResourceHints hints, @Nullable ClassLoader classLoader) {
ClassLoader classLoaderToUse = (classLoader != null) ? classLoader : getClass().getClassLoader();
ClassLoader classLoaderToUse = (classLoader != null ? classLoader : getClass().getClassLoader());
List<String> includes = new ArrayList<>();
for (String location : this.locations) {
if (classLoaderToUse.getResource(location) != null) {