Intellij suggested changes from static code analysis.

This commit is contained in:
Koen De Groote 2020-01-28 16:18:07 +01:00
parent b6773f6983
commit aff31ebd1b
8 changed files with 46 additions and 47 deletions

View File

@ -129,8 +129,7 @@ public class Time {
* @see #toString(String) * @see #toString(String)
*/ */
public String toString() { public String toString() {
return "" + getMinutes() + ":" return getMinutes() + ":" + (getSeconds() < 10 ? "0" : "") + getSeconds();
+ (getSeconds() < 10 ? "0" : "") + getSeconds();
} }
/** /**

View File

@ -404,7 +404,7 @@ class SecondsFormatter extends TimeFormatter {
// Else return it with leading 0's // Else return it with leading 0's
//return StringUtil.formatNumber(t.getSeconds(), digits); //return StringUtil.formatNumber(t.getSeconds(), digits);
return StringUtil.pad("" + t.getSeconds(), digits, "0", true); return StringUtil.pad(String.valueOf(t.getSeconds()), digits, "0", true);
} }
} }
@ -425,7 +425,7 @@ class MinutesFormatter extends TimeFormatter {
// Else return it with leading 0's // Else return it with leading 0's
//return StringUtil.formatNumber(t.getMinutes(), digits); //return StringUtil.formatNumber(t.getMinutes(), digits);
return StringUtil.pad("" + t.getMinutes(), digits, "0", true); return StringUtil.pad(String.valueOf(t.getMinutes()), digits, "0", true);
} }
} }

View File

@ -200,11 +200,10 @@ public final class TIFFUtilities {
} }
public static List<TIFFPage> getPages(ImageInputStream imageInput) throws IOException { public static List<TIFFPage> getPages(ImageInputStream imageInput) throws IOException {
ArrayList<TIFFPage> pages = new ArrayList<TIFFPage>();
CompoundDirectory IFDs = (CompoundDirectory) new TIFFReader().read(imageInput); CompoundDirectory IFDs = (CompoundDirectory) new TIFFReader().read(imageInput);
int pageCount = IFDs.directoryCount(); final int pageCount = IFDs.directoryCount();
List<TIFFPage> pages = new ArrayList<>(pageCount);
for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) {
pages.add(new TIFFPage(IFDs.getDirectory(pageIndex), imageInput)); pages.add(new TIFFPage(IFDs.getDirectory(pageIndex), imageInput));
} }

View File

@ -701,10 +701,10 @@ abstract class DIBImageReader extends ImageReaderBase {
} }
}); });
button.setText("" + image.getWidth() + "x" + button.setText(image.getWidth() + "x" +
image.getHeight() + ": " image.getHeight() + ": "
+ ((image.getColorModel() instanceof IndexColorModel) ? + ((image.getColorModel() instanceof IndexColorModel) ?
"" + ((IndexColorModel) image.getColorModel()).getMapSize() : String.valueOf(((IndexColorModel) image.getColorModel()).getMapSize()) :
"TrueColor")); "TrueColor"));
pParent.add(button); pParent.add(button);

View File

@ -144,7 +144,7 @@ public final class XMPReader extends MetadataReader {
parseAttributesForKnownElements(subsubdirs, node); parseAttributesForKnownElements(subsubdirs, node);
if (!subsubdirs.isEmpty()) { if (!subsubdirs.isEmpty()) {
List<Entry> entries = new ArrayList<Entry>(); List<Entry> entries = new ArrayList<>(subsubdirs.size());
for (Map.Entry<String, List<Entry>> entry : subsubdirs.entrySet()) { for (Map.Entry<String, List<Entry>> entry : subsubdirs.entrySet()) {
entries.addAll(entry.getValue()); entries.addAll(entry.getValue());
@ -161,7 +161,7 @@ public final class XMPReader extends MetadataReader {
} }
} }
List<Directory> entries = new ArrayList<Directory>(); List<Directory> entries = new ArrayList<Directory>(subdirs.size());
// TODO: Should we still allow asking for a subdirectory by item id? // TODO: Should we still allow asking for a subdirectory by item id?
for (Map.Entry<String, List<Entry>> entry : subdirs.entrySet()) { for (Map.Entry<String, List<Entry>> entry : subdirs.entrySet()) {

View File

@ -421,7 +421,7 @@ public final class ThumbsDBImageReader extends ImageReaderBase {
return SIZE; return SIZE;
} }
}); });
label.setText("" + image.getWidth() + "x" + image.getHeight() + ": " + pName); label.setText(image.getWidth() + "x" + image.getHeight() + ": " + pName);
label.setToolTipText(image.toString()); label.setToolTipText(image.toString());
pParent.add(label); pParent.add(label);
} }

View File

@ -1144,10 +1144,11 @@ public final class TIFFImageMetadata extends AbstractMetadata {
throw new IIOInvalidTreeException("Expected \"TIFFIFD\" node", ifdNode); throw new IIOInvalidTreeException("Expected \"TIFFIFD\" node", ifdNode);
} }
List<Entry> entries = new ArrayList<>();
NodeList nodes = ifdNode.getChildNodes(); NodeList nodes = ifdNode.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) { final int size = nodes.getLength();
List<Entry> entries = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
entries.add(toEntry(nodes.item(i))); entries.add(toEntry(nodes.item(i)));
} }