Polish ternary expressions

Consistently format ternary expressions and always favor `!=` as the
the check.
This commit is contained in:
Phillip Webb
2018-05-02 12:41:51 -07:00
parent 690f946b6d
commit 3ee777e142
199 changed files with 419 additions and 412 deletions

View File

@@ -95,7 +95,7 @@ public class DefaultLaunchScript implements LaunchScript {
value = (String) properties.get(name);
}
else {
value = (value == null ? matcher.group(0) : value.substring(1));
value = (value != null ? value.substring(1) : matcher.group(0));
}
matcher.appendReplacement(expanded, value.replace("$", "\\$"));
}

View File

@@ -332,7 +332,7 @@ public class JarWriter implements LoaderClassesWriter {
@Override
public int read() throws IOException {
int read = (this.headerStream == null ? -1 : this.headerStream.read());
int read = (this.headerStream != null ? this.headerStream.read() : -1);
if (read != -1) {
this.headerStream = null;
return read;
@@ -347,8 +347,8 @@ public class JarWriter implements LoaderClassesWriter {
@Override
public int read(byte[] b, int off, int len) throws IOException {
int read = (this.headerStream == null ? -1
: this.headerStream.read(b, off, len));
int read = (this.headerStream != null ? this.headerStream.read(b, off, len)
: -1);
if (read != -1) {
this.headerStream = null;
return read;

View File

@@ -63,7 +63,7 @@ public class Library {
* @param unpackRequired if the library needs to be unpacked before it can be used
*/
public Library(String name, File file, LibraryScope scope, boolean unpackRequired) {
this.name = (name == null ? file.getName() : name);
this.name = (name != null ? name : file.getName());
this.file = file;
this.scope = scope;
this.unpackRequired = unpackRequired;

View File

@@ -516,8 +516,8 @@ public abstract class MainClassFinder {
"Unable to find a single main class from the following candidates "
+ matchingMainClasses);
}
return matchingMainClasses.isEmpty() ? null
: matchingMainClasses.iterator().next().getName();
return (matchingMainClasses.isEmpty() ? null
: matchingMainClasses.iterator().next().getName());
}
}