Polish ternary expressions
Consistently format ternary expressions and always favor `!=` as the the check.
This commit is contained in:
@@ -423,7 +423,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|
||||
this.metadataCollector.add(ItemMetadata.newProperty(endpointKey, "enabled",
|
||||
Boolean.class.getName(), type, null,
|
||||
String.format("Whether to enable the %s endpoint.", endpointId),
|
||||
(enabledByDefault == null ? true : enabledByDefault), null));
|
||||
(enabledByDefault != null ? enabledByDefault : true), null));
|
||||
if (hasMainReadOperation(element)) {
|
||||
this.metadataCollector.add(ItemMetadata.newProperty(endpointKey,
|
||||
"cache.time-to-live", Duration.class.getName(), type, null,
|
||||
|
||||
@@ -178,7 +178,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
|
||||
String type = instance.toString();
|
||||
type = type.substring(DURATION_OF.length(), type.indexOf('('));
|
||||
String suffix = DURATION_SUFFIX.get(type);
|
||||
return (suffix == null ? null : factoryValue + suffix);
|
||||
return (suffix != null ? factoryValue + suffix : null);
|
||||
}
|
||||
return factoryValue;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class SpringBootExtension {
|
||||
|
||||
private String determineArtifactBaseName() {
|
||||
Jar artifactTask = findArtifactTask();
|
||||
return (artifactTask == null ? null : artifactTask.getBaseName());
|
||||
return (artifactTask != null ? artifactTask.getBaseName() : null);
|
||||
}
|
||||
|
||||
private Jar findArtifactTask() {
|
||||
|
||||
@@ -162,9 +162,9 @@ final class JavaPluginAction implements PluginApplicationAction {
|
||||
}
|
||||
|
||||
private boolean hasConfigurationProcessorOnClasspath(JavaCompile compile) {
|
||||
Set<File> files = compile.getOptions().getAnnotationProcessorPath() != null
|
||||
Set<File> files = (compile.getOptions().getAnnotationProcessorPath() != null
|
||||
? compile.getOptions().getAnnotationProcessorPath().getFiles()
|
||||
: compile.getClasspath().getFiles();
|
||||
: compile.getClasspath().getFiles());
|
||||
return files.stream().map(File::getName).anyMatch(
|
||||
(name) -> name.startsWith("spring-boot-configuration-processor"));
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ public class BuildInfo extends ConventionTask {
|
||||
new File(getDestinationDir(), "build-info.properties"))
|
||||
.writeBuildProperties(new ProjectDetails(
|
||||
this.properties.getGroup(),
|
||||
this.properties.getArtifact() == null
|
||||
? "unspecified"
|
||||
: this.properties.getArtifact(),
|
||||
this.properties.getArtifact() != null
|
||||
? this.properties.getArtifact()
|
||||
: "unspecified",
|
||||
this.properties.getVersion(),
|
||||
this.properties.getName(), this.properties.getTime(),
|
||||
coerceToStringValues(
|
||||
@@ -77,8 +77,8 @@ public class BuildInfo extends ConventionTask {
|
||||
*/
|
||||
@OutputDirectory
|
||||
public File getDestinationDir() {
|
||||
return this.destinationDir != null ? this.destinationDir
|
||||
: getProject().getBuildDir();
|
||||
return (this.destinationDir != null ? this.destinationDir
|
||||
: getProject().getBuildDir());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,8 +54,8 @@ public class BootJar extends Jar implements BootArchive {
|
||||
|
||||
private Action<CopySpec> classpathFiles(Spec<File> filter) {
|
||||
return (copySpec) -> copySpec
|
||||
.from((Callable<Iterable<File>>) () -> this.classpath == null
|
||||
? Collections.emptyList() : this.classpath.filter(filter));
|
||||
.from((Callable<Iterable<File>>) () -> (this.classpath != null
|
||||
? this.classpath.filter(filter) : Collections.emptyList()));
|
||||
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class BootJar extends Jar implements BootArchive {
|
||||
public void classpath(Object... classpath) {
|
||||
FileCollection existingClasspath = this.classpath;
|
||||
this.classpath = getProject().files(
|
||||
existingClasspath == null ? Collections.emptyList() : existingClasspath,
|
||||
existingClasspath != null ? existingClasspath : Collections.emptyList(),
|
||||
classpath);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ public class BootWar extends War implements BootArchive {
|
||||
public BootWar() {
|
||||
getWebInf().into("lib-provided",
|
||||
(copySpec) -> copySpec.from(
|
||||
(Callable<Iterable<File>>) () -> this.providedClasspath == null
|
||||
? Collections.emptyList() : this.providedClasspath));
|
||||
(Callable<Iterable<File>>) () -> (this.providedClasspath != null
|
||||
? this.providedClasspath : Collections.emptyList())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,7 +120,7 @@ public class BootWar extends War implements BootArchive {
|
||||
public void providedClasspath(Object... classpath) {
|
||||
FileCollection existingClasspath = this.providedClasspath;
|
||||
this.providedClasspath = getProject().files(
|
||||
existingClasspath == null ? Collections.emptyList() : existingClasspath,
|
||||
existingClasspath != null ? existingClasspath : Collections.emptyList(),
|
||||
classpath);
|
||||
}
|
||||
|
||||
|
||||
@@ -284,8 +284,8 @@ class BootZipCopyAction implements CopyAction {
|
||||
}
|
||||
|
||||
private long getTime(FileCopyDetails details) {
|
||||
return this.preserveFileTimestamps ? details.getLastModified()
|
||||
: CONSTANT_TIME_FOR_ZIP_ENTRIES;
|
||||
return (this.preserveFileTimestamps ? details.getLastModified()
|
||||
: CONSTANT_TIME_FOR_ZIP_ENTRIES);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ final class AsciiBytes {
|
||||
public boolean matches(CharSequence name, char suffix) {
|
||||
int charIndex = 0;
|
||||
int nameLen = name.length();
|
||||
int totalLen = (nameLen + (suffix == 0 ? 0 : 1));
|
||||
int totalLen = (nameLen + (suffix != 0 ? 1 : 0));
|
||||
for (int i = this.offset; i < this.offset + this.length; i++) {
|
||||
int b = this.bytes[i];
|
||||
int remainingUtfBytes = getNumberOfUtfBytes(b) - 1;
|
||||
@@ -250,7 +250,7 @@ final class AsciiBytes {
|
||||
}
|
||||
|
||||
public static int hashCode(int hash, char suffix) {
|
||||
return (suffix == 0 ? hash : (31 * hash + suffix));
|
||||
return (suffix != 0 ? (31 * hash + suffix) : hash);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class JarFile extends java.util.jar.JarFile {
|
||||
parser.addVisitor(centralDirectoryVisitor());
|
||||
this.data = parser.parse(data, filter == null);
|
||||
this.type = type;
|
||||
this.manifestSupplier = manifestSupplier != null ? manifestSupplier : () -> {
|
||||
this.manifestSupplier = (manifestSupplier != null ? manifestSupplier : () -> {
|
||||
try (InputStream inputStream = getInputStream(MANIFEST_NAME)) {
|
||||
if (inputStream == null) {
|
||||
return null;
|
||||
@@ -130,7 +130,7 @@ public class JarFile extends java.util.jar.JarFile {
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private CentralDirectoryVisitor centralDirectoryVisitor() {
|
||||
|
||||
@@ -36,7 +36,7 @@ final class StringSequence implements CharSequence {
|
||||
private int hash;
|
||||
|
||||
StringSequence(String source) {
|
||||
this(source, 0, (source == null ? -1 : source.length()));
|
||||
this(source, 0, source != null ? source.length() : -1);
|
||||
}
|
||||
|
||||
StringSequence(String source, int start, int end) {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer
|
||||
|
||||
private void process(String name, String value) {
|
||||
String existing = this.data.getProperty(name);
|
||||
this.data.setProperty(name, (existing == null ? value : existing + "," + value));
|
||||
this.data.setProperty(name, (existing != null ? existing + "," + value : value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user