Use some diamond operators just for kicks.

This commit is contained in:
Michael Bayne
2017-09-17 10:31:58 -07:00
parent d8fa95e15c
commit 167ea2c5d5
13 changed files with 59 additions and 59 deletions
@@ -304,7 +304,7 @@ public class Application
*/ */
public List<Resource> getAllActiveResources () public List<Resource> getAllActiveResources ()
{ {
List<Resource> allResources = new ArrayList<Resource>(); List<Resource> allResources = new ArrayList<>();
allResources.addAll(getActiveCodeResources()); allResources.addAll(getActiveCodeResources());
allResources.addAll(getActiveResources()); allResources.addAll(getActiveResources());
return allResources; return allResources;
@@ -350,7 +350,7 @@ public class Application
*/ */
public List<Resource> getActiveCodeResources () public List<Resource> getActiveCodeResources ()
{ {
ArrayList<Resource> codes = new ArrayList<Resource>(); ArrayList<Resource> codes = new ArrayList<>();
codes.addAll(getCodeResources()); codes.addAll(getCodeResources());
for (AuxGroup aux : getAuxGroups()) { for (AuxGroup aux : getAuxGroups()) {
if (isAuxGroupActive(aux.name)) { if (isAuxGroupActive(aux.name)) {
@@ -365,7 +365,7 @@ public class Application
*/ */
public List<Resource> getActiveResources () public List<Resource> getActiveResources ()
{ {
ArrayList<Resource> rsrcs = new ArrayList<Resource>(); ArrayList<Resource> rsrcs = new ArrayList<>();
rsrcs.addAll(getResources()); rsrcs.addAll(getResources());
for (AuxGroup aux : getAuxGroups()) { for (AuxGroup aux : getAuxGroups()) {
if (isAuxGroupActive(aux.name)) { if (isAuxGroupActive(aux.name)) {
@@ -529,7 +529,7 @@ public class Application
if (cdata == null) { if (cdata == null) {
String appbase = SysProps.appBase(); String appbase = SysProps.appBase();
log.info("Attempting to obtain 'appbase' from system property", "appbase", appbase); log.info("Attempting to obtain 'appbase' from system property", "appbase", appbase);
cdata = new HashMap<String,Object>(); cdata = new HashMap<>();
cdata.put("appbase", appbase); cdata.put("appbase", appbase);
} }
@@ -622,12 +622,12 @@ public class Application
// check for tracking progress percent configuration // check for tracking progress percent configuration
String trackPcts = (String)cdata.get("tracking_percents"); String trackPcts = (String)cdata.get("tracking_percents");
if (!StringUtil.isBlank(trackPcts)) { if (!StringUtil.isBlank(trackPcts)) {
_trackingPcts = new HashSet<Integer>(); _trackingPcts = new HashSet<>();
for (int pct : StringUtil.parseIntArray(trackPcts)) { for (int pct : StringUtil.parseIntArray(trackPcts)) {
_trackingPcts.add(pct); _trackingPcts.add(pct);
} }
} else if (!StringUtil.isBlank(_trackingURL)) { } else if (!StringUtil.isBlank(_trackingURL)) {
_trackingPcts = new HashSet<Integer>(); _trackingPcts = new HashSet<>();
_trackingPcts.add(50); _trackingPcts.add(50);
} }
@@ -663,10 +663,10 @@ public class Application
// parse our auxiliary resource groups // parse our auxiliary resource groups
for (String auxgroup : parseList(cdata, "auxgroups")) { for (String auxgroup : parseList(cdata, "auxgroups")) {
ArrayList<Resource> codes = new ArrayList<Resource>(); ArrayList<Resource> codes = new ArrayList<>();
parseResources(cdata, auxgroup + ".code", false, codes); parseResources(cdata, auxgroup + ".code", false, codes);
parseResources(cdata, auxgroup + ".ucode", true, codes); parseResources(cdata, auxgroup + ".ucode", true, codes);
ArrayList<Resource> rsrcs = new ArrayList<Resource>(); ArrayList<Resource> rsrcs = new ArrayList<>();
parseResources(cdata, auxgroup + ".resource", false, rsrcs); parseResources(cdata, auxgroup + ".resource", false, rsrcs);
parseResources(cdata, auxgroup + ".uresource", true, rsrcs); parseResources(cdata, auxgroup + ".uresource", true, rsrcs);
_auxgroups.put(auxgroup, new AuxGroup(auxgroup, codes, rsrcs)); _auxgroups.put(auxgroup, new AuxGroup(auxgroup, codes, rsrcs));
@@ -945,7 +945,7 @@ public class Application
public Process createProcess (boolean optimum) public Process createProcess (boolean optimum)
throws IOException throws IOException
{ {
ArrayList<String> args = new ArrayList<String>(); ArrayList<String> args = new ArrayList<>();
// reconstruct the path to the JVM // reconstruct the path to the JVM
args.add(LaunchUtil.getJVMPath(_appdir, _windebug || optimum)); args.add(LaunchUtil.getJVMPath(_appdir, _windebug || optimum));
@@ -1033,14 +1033,14 @@ public class Application
*/ */
protected String[] createEnvironment () protected String[] createEnvironment ()
{ {
List<String> envvar = new ArrayList<String>(); List<String> envvar = new ArrayList<>();
fillAssignmentListFromPairs("env.txt", envvar); fillAssignmentListFromPairs("env.txt", envvar);
if (envvar.isEmpty()) { if (envvar.isEmpty()) {
log.info("Didn't find any custom environment variables, not setting any."); log.info("Didn't find any custom environment variables, not setting any.");
return null; return null;
} }
List<String> envAssignments = new ArrayList<String>(); List<String> envAssignments = new ArrayList<>();
for (String assignment : envvar) { for (String assignment : envvar) {
envAssignments.add(processArg(assignment)); envAssignments.add(processArg(assignment));
} }
@@ -1087,7 +1087,7 @@ public class Application
} }
// pass along any pass-through arguments // pass along any pass-through arguments
Map<String, String> passProps = new HashMap<String, String>(); Map<String, String> passProps = new HashMap<>();
for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) { for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
String key = (String)entry.getKey(); String key = (String)entry.getKey();
if (key.startsWith(PROP_PASSTHROUGH_PREFIX)) { if (key.startsWith(PROP_PASSTHROUGH_PREFIX)) {
@@ -1317,9 +1317,9 @@ public class Application
final boolean noUnpack = SysProps.noUnpack(); final boolean noUnpack = SysProps.noUnpack();
final int[] fAlreadyValid = alreadyValid; final int[] fAlreadyValid = alreadyValid;
final Set<Resource> toInstallAsync = new ConcurrentSkipListSet<Resource>(toInstall); final Set<Resource> toInstallAsync = new ConcurrentSkipListSet<>(toInstall);
final Set<Resource> toDownloadAsync = new ConcurrentSkipListSet<Resource>(); final Set<Resource> toDownloadAsync = new ConcurrentSkipListSet<>();
final Set<Resource> unpackedAsync = new ConcurrentSkipListSet<Resource>(); final Set<Resource> unpackedAsync = new ConcurrentSkipListSet<>();
for (int ii = 0; ii < sizes.length; ii++) { for (int ii = 0; ii < sizes.length; ii++) {
final Resource rsrc = rsrcs.get(ii); final Resource rsrc = rsrcs.get(ii);
@@ -1717,7 +1717,7 @@ public class Application
*/ */
public static List<Integer> intsToList (int[] values) public static List<Integer> intsToList (int[] values)
{ {
List<Integer> list = new ArrayList<Integer>(values.length); List<Integer> list = new ArrayList<>(values.length);
for (int val : values) { for (int val : values) {
list.add(val); list.add(val);
} }
@@ -1894,24 +1894,24 @@ public class Application
protected boolean _javaExactVersionRequired; protected boolean _javaExactVersionRequired;
protected String _javaLocation; protected String _javaLocation;
protected List<Resource> _codes = new ArrayList<Resource>(); protected List<Resource> _codes = new ArrayList<>();
protected List<Resource> _resources = new ArrayList<Resource>(); protected List<Resource> _resources = new ArrayList<>();
protected boolean _useCodeCache; protected boolean _useCodeCache;
protected int _codeCacheRetentionDays; protected int _codeCacheRetentionDays;
protected Map<String,AuxGroup> _auxgroups = new HashMap<String,AuxGroup>(); protected Map<String,AuxGroup> _auxgroups = new HashMap<>();
protected Map<String,Boolean> _auxactive = new HashMap<String,Boolean>(); protected Map<String,Boolean> _auxactive = new HashMap<>();
protected List<String> _jvmargs = new ArrayList<String>(); protected List<String> _jvmargs = new ArrayList<>();
protected List<String> _appargs = new ArrayList<String>(); protected List<String> _appargs = new ArrayList<>();
protected String[] _extraJvmArgs; protected String[] _extraJvmArgs;
protected String[] _extraAppArgs; protected String[] _extraAppArgs;
protected String[] _optimumJvmArgs; protected String[] _optimumJvmArgs;
protected List<String> _txtJvmArgs = new ArrayList<String>(); protected List<String> _txtJvmArgs = new ArrayList<>();
protected List<Certificate> _signers; protected List<Certificate> _signers;
@@ -49,13 +49,13 @@ public class Digest
{ {
// first compute the digests for all the resources in parallel // first compute the digests for all the resources in parallel
Executor exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); Executor exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
final Map<Resource, String> digests = new ConcurrentHashMap<Resource, String>(); final Map<Resource, String> digests = new ConcurrentHashMap<>();
final BlockingQueue<Object> completed = new LinkedBlockingQueue<Object>(); final BlockingQueue<Object> completed = new LinkedBlockingQueue<>();
final int fversion = version; final int fversion = version;
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Set<Resource> pending = new HashSet<Resource>(resources); Set<Resource> pending = new HashSet<>(resources);
for (final Resource rsrc : resources) { for (final Resource rsrc : resources) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
public void run () { public void run () {
@@ -212,7 +212,7 @@ public class Digest
data.append(path).append(" = ").append(digest).append("\n"); data.append(path).append(" = ").append(digest).append("\n");
} }
protected HashMap<String, String> _digests = new HashMap<String, String>(); protected HashMap<String, String> _digests = new HashMap<>();
protected String _metaDigest = ""; protected String _metaDigest = "";
protected static final String FILE_NAME = "digest"; protected static final String FILE_NAME = "digest";
@@ -430,9 +430,9 @@ public abstract class Getdown extends Thread
int[] alreadyValid = new int[1]; int[] alreadyValid = new int[1];
// we'll keep track of all the resources we unpack // we'll keep track of all the resources we unpack
Set<Resource> unpacked = new HashSet<Resource>(); Set<Resource> unpacked = new HashSet<>();
_toInstallResources = new HashSet<Resource>(); _toInstallResources = new HashSet<>();
_readyToInstall = false; _readyToInstall = false;
//setStep(Step.START); //setStep(Step.START);
@@ -466,7 +466,7 @@ public abstract class Getdown extends Thread
// now verify our resources... // now verify our resources...
setStep(Step.VERIFY_RESOURCES); setStep(Step.VERIFY_RESOURCES);
setStatusAsync("m.validating", -1, -1L, false); setStatusAsync("m.validating", -1, -1L, false);
Set<Resource> toDownload = new HashSet<Resource>(); Set<Resource> toDownload = new HashSet<>();
_app.verifyResources(_progobs, alreadyValid, unpacked, _app.verifyResources(_progobs, alreadyValid, unpacked,
_toInstallResources, toDownload); _toInstallResources, toDownload);
if (toDownload.size() == 0) { if (toDownload.size() == 0) {
@@ -622,7 +622,7 @@ public abstract class Getdown extends Thread
reportTrackingEvent("jvm_start", -1); reportTrackingEvent("jvm_start", -1);
updateStatus("m.downloading_java"); updateStatus("m.downloading_java");
List<Resource> list = new ArrayList<Resource>(); List<Resource> list = new ArrayList<>();
list.add(vmjar); list.add(vmjar);
download(list); download(list);
@@ -682,7 +682,7 @@ public abstract class Getdown extends Thread
// attempt to download the patch files // attempt to download the patch files
Resource patch = _app.getPatchResource(null); Resource patch = _app.getPatchResource(null);
if (patch != null) { if (patch != null) {
List<Resource> list = new ArrayList<Resource>(); List<Resource> list = new ArrayList<>();
list.add(patch); list.add(patch);
// add the auxiliary group patch files for activated groups // add the auxiliary group patch files for activated groups
@@ -88,7 +88,7 @@ public class GetdownApp
// load X.509 certificate if it exists // load X.509 certificate if it exists
File crtFile = new File(appDir, Digest.digestFile(Digest.VERSION) + ".crt"); File crtFile = new File(appDir, Digest.digestFile(Digest.VERSION) + ".crt");
List<Certificate> crts = new ArrayList<Certificate>(); List<Certificate> crts = new ArrayList<>();
if (crtFile.exists()) { if (crtFile.exists()) {
try { try {
FileInputStream fis = new FileInputStream(crtFile); FileInputStream fis = new FileInputStream(crtFile);
@@ -148,7 +148,7 @@ public class GetdownApp
} }
if (_ifc.iconImages != null) { if (_ifc.iconImages != null) {
ArrayList<Image> icons = new ArrayList<Image>(); ArrayList<Image> icons = new ArrayList<>();
for (String path : _ifc.iconImages) { for (String path : _ifc.iconImages) {
Image img = loadImage(path); Image img = loadImage(path);
if (img == null) { if (img == null) {
@@ -85,7 +85,7 @@ public class GetdownApplet extends JApplet
_errmsg = e.getMessage(); _errmsg = e.getMessage();
} }
List<Certificate> signers = new ArrayList<Certificate>(); List<Certificate> signers = new ArrayList<>();
Certificate cert = loadCertificate("resource.crt"); Certificate cert = loadCertificate("resource.crt");
if (cert != null) { if (cert != null) {
signers.add(cert); signers.add(cert);
@@ -299,7 +299,7 @@ public class GetdownAppletConfig
*/ */
protected List<String> parseArgList (String prefix) protected List<String> parseArgList (String prefix)
{ {
List<String> arglist = new ArrayList<String>(); List<String> arglist = new ArrayList<>();
String value; String value;
for (int ii = 0; (value = getParameter(prefix + ii)) != null; ii++) { for (int ii = 0; (value = getParameter(prefix + ii)) != null; ii++) {
arglist.add(value); arglist.add(value);
@@ -234,10 +234,10 @@ public abstract class Downloader extends Thread
protected Collection<Resource> _resources; protected Collection<Resource> _resources;
/** The reported sizes of our resources. */ /** The reported sizes of our resources. */
protected Map<Resource, Long> _sizes = new HashMap<Resource, Long>(); protected Map<Resource, Long> _sizes = new HashMap<>();
/** The bytes downloaded for each resource. */ /** The bytes downloaded for each resource. */
protected Map<Resource, Long> _downloaded = new HashMap<Resource, Long>(); protected Map<Resource, Long> _downloaded = new HashMap<>();
/** The observer with whom we are communicating. */ /** The observer with whom we are communicating. */
protected Observer _obs; protected Observer _obs;
@@ -60,13 +60,13 @@ public class Differ
Application oapp = new Application(ovdir, null); Application oapp = new Application(ovdir, null);
oapp.init(false); oapp.init(false);
ArrayList<Resource> orsrcs = new ArrayList<Resource>(); ArrayList<Resource> orsrcs = new ArrayList<>();
orsrcs.addAll(oapp.getCodeResources()); orsrcs.addAll(oapp.getCodeResources());
orsrcs.addAll(oapp.getResources()); orsrcs.addAll(oapp.getResources());
Application napp = new Application(nvdir, null); Application napp = new Application(nvdir, null);
napp.init(false); napp.init(false);
ArrayList<Resource> nrsrcs = new ArrayList<Resource>(); ArrayList<Resource> nrsrcs = new ArrayList<>();
nrsrcs.addAll(napp.getCodeResources()); nrsrcs.addAll(napp.getCodeResources());
nrsrcs.addAll(napp.getResources()); nrsrcs.addAll(napp.getResources());
@@ -76,13 +76,13 @@ public class Differ
// next create patches for any auxiliary resource groups // next create patches for any auxiliary resource groups
for (Application.AuxGroup ag : napp.getAuxGroups()) { for (Application.AuxGroup ag : napp.getAuxGroups()) {
orsrcs = new ArrayList<Resource>(); orsrcs = new ArrayList<>();
Application.AuxGroup oag = oapp.getAuxGroup(ag.name); Application.AuxGroup oag = oapp.getAuxGroup(ag.name);
if (oag != null) { if (oag != null) {
orsrcs.addAll(oag.codes); orsrcs.addAll(oag.codes);
orsrcs.addAll(oag.rsrcs); orsrcs.addAll(oag.rsrcs);
} }
nrsrcs = new ArrayList<Resource>(); nrsrcs = new ArrayList<>();
nrsrcs.addAll(ag.codes); nrsrcs.addAll(ag.codes);
nrsrcs.addAll(ag.rsrcs); nrsrcs.addAll(ag.rsrcs);
patch = new File(nvdir, "patch-" + ag.name + overs + ".dat"); patch = new File(nvdir, "patch-" + ag.name + overs + ".dat");
@@ -76,7 +76,7 @@ public class Digester
Application app = new Application(appdir, null); Application app = new Application(appdir, null);
app.init(false); app.init(false);
List<Resource> rsrcs = new ArrayList<Resource>(); List<Resource> rsrcs = new ArrayList<>();
rsrcs.add(app.getConfigResource()); rsrcs.add(app.getConfigResource());
rsrcs.addAll(app.getCodeResources()); rsrcs.addAll(app.getCodeResources());
rsrcs.addAll(app.getResources()); rsrcs.addAll(app.getResources());
@@ -73,10 +73,10 @@ public class JarDiff implements JarDiffCodes
JarFile2 newJar = new JarFile2(newPath); JarFile2 newJar = new JarFile2(newPath);
try { try {
HashMap<String,String> moved = new HashMap<String,String>(); HashMap<String,String> moved = new HashMap<>();
HashSet<String> implicit = new HashSet<String>(); HashSet<String> implicit = new HashSet<>();
HashSet<String> moveSrc = new HashSet<String>(); HashSet<String> moveSrc = new HashSet<>();
HashSet<String> newEntries = new HashSet<String>(); HashSet<String> newEntries = new HashSet<>();
// FIRST PASS // FIRST PASS
// Go through the entries in new jar and // Go through the entries in new jar and
@@ -152,7 +152,7 @@ public class JarDiff implements JarDiffCodes
// SECOND PASS: <deleted files> = <oldjarnames> - <implicitmoves> - // SECOND PASS: <deleted files> = <oldjarnames> - <implicitmoves> -
// <source of move commands> - <new or modified entries> // <source of move commands> - <new or modified entries>
ArrayList<String> deleted = new ArrayList<String>(); ArrayList<String> deleted = new ArrayList<>();
for (JarEntry oldEntry : oldJar) { for (JarEntry oldEntry : oldJar) {
String oldName = oldEntry.getName(); String oldName = oldEntry.getName();
if (!implicit.contains(oldName) && !moveSrc.contains(oldName) if (!implicit.contains(oldName) && !moveSrc.contains(oldName)
@@ -452,9 +452,9 @@ public class JarDiff implements JarDiffCodes
private void index () throws IOException { private void index () throws IOException {
Enumeration<JarEntry> entries = _jar.entries(); Enumeration<JarEntry> entries = _jar.entries();
_nameToEntryMap = new HashMap<String,JarEntry>(); _nameToEntryMap = new HashMap<>();
_crcToEntryMap = new HashMap<Long,LinkedList<JarEntry>>(); _crcToEntryMap = new HashMap<>();
_entries = new ArrayList<JarEntry>(); _entries = new ArrayList<>();
if (_debug) { if (_debug) {
System.out.println("indexing: " + _jar.getName()); System.out.println("indexing: " + _jar.getName());
} }
@@ -54,16 +54,16 @@ public class JarDiffPatcher implements JarDiffCodes
jos = new JarOutputStream(new FileOutputStream(target)); jos = new JarOutputStream(new FileOutputStream(target));
oldJar = new JarFile(oldFile); oldJar = new JarFile(oldFile);
jarDiff = new JarFile(diffFile); jarDiff = new JarFile(diffFile);
Set<String> ignoreSet = new HashSet<String>(); Set<String> ignoreSet = new HashSet<>();
Map<String, String> renameMap = new HashMap<String, String>(); Map<String, String> renameMap = new HashMap<>();
determineNameMapping(jarDiff, ignoreSet, renameMap); determineNameMapping(jarDiff, ignoreSet, renameMap);
// get all keys in renameMap // get all keys in renameMap
String[] keys = renameMap.keySet().toArray(new String[renameMap.size()]); String[] keys = renameMap.keySet().toArray(new String[renameMap.size()]);
// Files to implicit move // Files to implicit move
Set<String> oldjarNames = new HashSet<String>(); Set<String> oldjarNames = new HashSet<>();
Enumeration<JarEntry> oldEntries = oldJar.entries(); Enumeration<JarEntry> oldEntries = oldJar.entries();
if (oldEntries != null) { if (oldEntries != null) {
while (oldEntries.hasMoreElements()) { while (oldEntries.hasMoreElements()) {
@@ -223,7 +223,7 @@ public class JarDiffPatcher implements JarDiffCodes
{ {
int index = 0; int index = 0;
int length = path.length(); int length = path.length();
ArrayList<String> sub = new ArrayList<String>(); ArrayList<String> sub = new ArrayList<>();
while (index < length) { while (index < length) {
while (index < length && Character.isWhitespace while (index < length && Character.isWhitespace
@@ -72,7 +72,7 @@ public class ConfigUtil
*/ */
public static List<String[]> parsePairs (Reader source, ParseOpts opts) throws IOException public static List<String[]> parsePairs (Reader source, ParseOpts opts) throws IOException
{ {
List<String[]> pairs = new ArrayList<String[]>(); List<String[]> pairs = new ArrayList<>();
for (String line : FileUtil.readLines(source)) { for (String line : FileUtil.readLines(source)) {
// nix comments // nix comments
int cidx = line.indexOf("#"); int cidx = line.indexOf("#");
@@ -133,7 +133,7 @@ public class ConfigUtil
public static Map<String, Object> parseConfig (File source, ParseOpts opts) public static Map<String, Object> parseConfig (File source, ParseOpts opts)
throws IOException throws IOException
{ {
Map<String, Object> data = new HashMap<String, Object>(); Map<String, Object> data = new HashMap<>();
// I thought that we could use HashMap<String, String[]> and put new String[] {pair[1]} for // I thought that we could use HashMap<String, String[]> and put new String[] {pair[1]} for
// the null case, but it mysteriously dies on launch, so leaving it as HashMap<String, // the null case, but it mysteriously dies on launch, so leaving it as HashMap<String,
@@ -86,7 +86,7 @@ public class FileUtil extends com.samskivert.util.FileUtil
public static List<String> readLines (Reader in) public static List<String> readLines (Reader in)
throws IOException throws IOException
{ {
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<>();
try { try {
BufferedReader bin = new BufferedReader(in); BufferedReader bin = new BufferedReader(in);
for (String line = null; (line = bin.readLine()) != null; lines.add(line)) {} for (String line = null; (line = bin.readLine()) != null; lines.add(line)) {}
@@ -156,7 +156,7 @@ public class FileUtil extends com.samskivert.util.FileUtil
*/ */
public static void walkTree (File root, Visitor visitor) public static void walkTree (File root, Visitor visitor)
{ {
Deque<File> stack = new ArrayDeque<File>(Arrays.asList(root.listFiles())); Deque<File> stack = new ArrayDeque<>(Arrays.asList(root.listFiles()));
while (!stack.isEmpty()) { while (!stack.isEmpty()) {
File currentFile = stack.pop(); File currentFile = stack.pop();
if (currentFile.exists()) { if (currentFile.exists()) {