Polish ternary expressions
Consistently format ternary expressions and always favor `!=` as the the check.
This commit is contained in:
@@ -116,8 +116,8 @@ public abstract class Launcher {
|
||||
protected final Archive createArchive() throws Exception {
|
||||
ProtectionDomain protectionDomain = getClass().getProtectionDomain();
|
||||
CodeSource codeSource = protectionDomain.getCodeSource();
|
||||
URI location = (codeSource == null ? null : codeSource.getLocation().toURI());
|
||||
String path = (location == null ? null : location.getSchemeSpecificPart());
|
||||
URI location = (codeSource != null ? codeSource.getLocation().toURI() : null);
|
||||
String path = (location != null ? location.getSchemeSpecificPart() : null);
|
||||
if (path == null) {
|
||||
throw new IllegalStateException("Unable to determine code source archive");
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MainMethodRunner {
|
||||
*/
|
||||
public MainMethodRunner(String mainClass, String[] args) {
|
||||
this.mainClassName = mainClass;
|
||||
this.args = (args == null ? null : args.clone());
|
||||
this.args = (args != null ? args.clone() : null);
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
|
||||
@@ -438,8 +438,9 @@ public class PropertiesLauncher extends Launcher {
|
||||
return SystemPropertyUtils.resolvePlaceholders(this.properties, value);
|
||||
}
|
||||
}
|
||||
return defaultValue == null ? defaultValue
|
||||
: SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue);
|
||||
return (defaultValue != null
|
||||
? SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue)
|
||||
: defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,11 +33,11 @@ public class ByteArrayRandomAccessData implements RandomAccessData {
|
||||
private final long length;
|
||||
|
||||
public ByteArrayRandomAccessData(byte[] bytes) {
|
||||
this(bytes, 0, (bytes == null ? 0 : bytes.length));
|
||||
this(bytes, 0, (bytes != null ? bytes.length : 0));
|
||||
}
|
||||
|
||||
public ByteArrayRandomAccessData(byte[] bytes, long offset, long length) {
|
||||
this.bytes = (bytes == null ? new byte[0] : bytes);
|
||||
this.bytes = (bytes != null ? bytes : new byte[0]);
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class RandomAccessDataFile implements RandomAccessData {
|
||||
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
return read(b, 0, b == null ? 0 : b.length);
|
||||
return read(b, 0, b != null ? b.length : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,7 +178,7 @@ public class RandomAccessDataFile implements RandomAccessData {
|
||||
}
|
||||
if (b == null) {
|
||||
int rtn = file.read();
|
||||
moveOn(rtn == -1 ? 0 : 1);
|
||||
moveOn(rtn != -1 ? 1 : 0);
|
||||
return rtn;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -103,7 +103,7 @@ final class CentralDirectoryFileHeader implements FileHeader {
|
||||
|
||||
@Override
|
||||
public boolean hasName(String name, String suffix) {
|
||||
return this.name.equals(new AsciiBytes(suffix == null ? name : name + suffix));
|
||||
return this.name.equals(new AsciiBytes(suffix != null ? name + suffix : name));
|
||||
}
|
||||
|
||||
public boolean isDirectory() {
|
||||
|
||||
@@ -250,7 +250,7 @@ public class Handler extends URLStreamHandler {
|
||||
}
|
||||
|
||||
private int hashCode(String protocol, String file) {
|
||||
int result = (protocol == null ? 0 : protocol.hashCode());
|
||||
int result = (protocol != null ? protocol.hashCode() : 0);
|
||||
int separatorIndex = file.indexOf(SEPARATOR);
|
||||
if (separatorIndex == -1) {
|
||||
return result + file.hashCode();
|
||||
@@ -319,7 +319,7 @@ public class Handler extends URLStreamHandler {
|
||||
String path = name.substring(FILE_PROTOCOL.length());
|
||||
File file = new File(URLDecoder.decode(path, "UTF-8"));
|
||||
Map<File, JarFile> cache = rootFileCache.get();
|
||||
JarFile result = (cache == null ? null : cache.get(file));
|
||||
JarFile result = (cache != null ? cache.get(file) : null);
|
||||
if (result == null) {
|
||||
result = new JarFile(file);
|
||||
addToRootFileCache(file, result);
|
||||
|
||||
@@ -71,7 +71,7 @@ class JarEntry extends java.util.jar.JarEntry implements FileHeader {
|
||||
@Override
|
||||
public Attributes getAttributes() throws IOException {
|
||||
Manifest manifest = this.jarFile.getManifest();
|
||||
return (manifest == null ? null : manifest.getAttributes(getName()));
|
||||
return (manifest != null ? manifest.getAttributes(getName()) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -154,7 +154,7 @@ public class JarFile extends java.util.jar.JarFile {
|
||||
|
||||
@Override
|
||||
public Manifest getManifest() throws IOException {
|
||||
Manifest manifest = (this.manifest == null ? null : this.manifest.get());
|
||||
Manifest manifest = (this.manifest != null ? this.manifest.get() : null);
|
||||
if (manifest == null) {
|
||||
if (this.type == JarFileType.NESTED_DIRECTORY) {
|
||||
manifest = new JarFile(this.getRootJarFile()).getManifest();
|
||||
@@ -219,7 +219,7 @@ public class JarFile extends java.util.jar.JarFile {
|
||||
if (ze instanceof JarEntry) {
|
||||
return this.entries.getInputStream((JarEntry) ze, access);
|
||||
}
|
||||
return getInputStream(ze == null ? null : ze.getName(), access);
|
||||
return getInputStream((ze != null ? ze.getName() : null), access);
|
||||
}
|
||||
|
||||
InputStream getInputStream(String name, ResourceAccess access) throws IOException {
|
||||
|
||||
@@ -280,7 +280,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
|
||||
}
|
||||
|
||||
private AsciiBytes applyFilter(AsciiBytes name) {
|
||||
return (this.filter == null ? name : this.filter.apply(name));
|
||||
return (this.filter != null ? this.filter.apply(name) : name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -205,7 +205,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
return this.jarFile.size();
|
||||
}
|
||||
JarEntry entry = getJarEntry();
|
||||
return (entry == null ? -1 : (int) entry.getSize());
|
||||
return (entry != null ? (int) entry.getSize() : -1);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
return -1;
|
||||
@@ -220,7 +220,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return (this.jarEntryName == null ? null : this.jarEntryName.getContentType());
|
||||
return (this.jarEntryName != null ? this.jarEntryName.getContentType() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -242,7 +242,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
}
|
||||
try {
|
||||
JarEntry entry = getJarEntry();
|
||||
return (entry == null ? 0 : entry.getTime());
|
||||
return (entry != null ? entry.getTime() : 0);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
return 0;
|
||||
|
||||
@@ -155,7 +155,7 @@ public abstract class SystemPropertyUtils {
|
||||
if (propVal != null) {
|
||||
return propVal;
|
||||
}
|
||||
return properties == null ? null : properties.getProperty(placeholderName);
|
||||
return (properties != null ? properties.getProperty(placeholderName) : null);
|
||||
}
|
||||
|
||||
public static String getProperty(String key) {
|
||||
@@ -189,8 +189,8 @@ public abstract class SystemPropertyUtils {
|
||||
}
|
||||
if (propVal == null) {
|
||||
// Try uppercase with underscores as well.
|
||||
propVal = System.getenv(key.toUpperCase(Locale.ENGLISH)
|
||||
.replace('.', '_'));
|
||||
propVal = System
|
||||
.getenv(key.toUpperCase(Locale.ENGLISH).replace('.', '_'));
|
||||
}
|
||||
if (propVal != null) {
|
||||
return propVal;
|
||||
|
||||
@@ -69,9 +69,9 @@ public class ExplodedArchiveTests {
|
||||
File file = this.temporaryFolder.newFile();
|
||||
TestJarCreator.createTestJar(file);
|
||||
|
||||
this.rootFolder = StringUtils.hasText(folderName)
|
||||
this.rootFolder = (StringUtils.hasText(folderName)
|
||||
? this.temporaryFolder.newFolder(folderName)
|
||||
: this.temporaryFolder.newFolder();
|
||||
: this.temporaryFolder.newFolder());
|
||||
JarFile jarFile = new JarFile(file);
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
|
||||
Reference in New Issue
Block a user