Polish ternary expressions

Consistently format ternary expressions and always favor `!=` as the
the check.
This commit is contained in:
Phillip Webb
2018-05-03 13:08:20 -07:00
parent bbf94c22da
commit 41efea51a7
128 changed files with 285 additions and 257 deletions

View File

@@ -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() {

View File

@@ -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"));
}

View File

@@ -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());
}
/**

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}
}