Enable PMD rule UseDiamondOperator and fix violations

This commit is contained in:
Manuel Fuhr 2023-05-09 22:06:55 +02:00
parent 2e1722150c
commit 7a6d3bd9d9
45 changed files with 105 additions and 105 deletions

View file

@ -25,7 +25,7 @@ public abstract class MapCreatorBase implements WayListener, NodeListener, Relat
protected Map<String, String> tags;
public void putTag(String key, String value) {
if (tags == null) tags = new HashMap<String, String>();
if (tags == null) tags = new HashMap<>();
tags.put(key, value);
}

View file

@ -105,7 +105,7 @@ public class OsmNodeP extends OsmLinkP {
}
public void checkDuplicateTargets() {
HashMap<OsmNodeP, OsmLinkP> targets = new HashMap<OsmNodeP, OsmLinkP>();
HashMap<OsmNodeP, OsmLinkP> targets = new HashMap<>();
for (OsmLinkP link0 = getFirstLink(); link0 != null; link0 = link0.getNext(this)) {
OsmLinkP link = link0;
@ -165,14 +165,14 @@ public class OsmNodeP extends OsmLinkP {
mc.writeVarBytes(getNodeDecsription());
// buffer internal reverse links
ArrayList<OsmNodeP> internalReverse = new ArrayList<OsmNodeP>();
ArrayList<OsmNodeP> internalReverse = new ArrayList<>();
for (OsmLinkP link0 = getFirstLink(); link0 != null; link0 = link0.getNext(this)) {
OsmLinkP link = link0;
OsmNodeP origin = this;
OsmNodeP target = null;
ArrayList<OsmNodeP> linkNodes = new ArrayList<OsmNodeP>();
ArrayList<OsmNodeP> linkNodes = new ArrayList<>();
linkNodes.add(this);
// first pass just to see if that link is consistent

View file

@ -52,7 +52,7 @@ public class OsmTrafficMap {
public OsmTrafficElement next;
}
private CompactLongMap<OsmTrafficElement> map = new CompactLongMap<OsmTrafficElement>();
private CompactLongMap<OsmTrafficElement> map = new CompactLongMap<>();
public void loadAll(File file, int minLon, int minLat, int maxLon, int maxLat, boolean includeMotorways) throws Exception {
load(file, minLon, minLat, maxLon, maxLat, includeMotorways);
@ -107,7 +107,7 @@ public class OsmTrafficMap {
is.close();
}
map = new FrozenLongMap<OsmTrafficElement>(map);
map = new FrozenLongMap<>(map);
System.out.println("read traffic-elements: " + trafficElements);
}

View file

@ -186,7 +186,7 @@ public class PosUnifier extends MapCreatorBase {
}
private void resetSrtm() {
srtmmap = new HashMap<String, SrtmRaster>();
srtmmap = new HashMap<>();
lastSrtmLonIdx = -1;
lastSrtmLatIdx = -1;
lastSrtmRaster = null;

View file

@ -53,7 +53,7 @@ public class RelationMerger extends MapCreatorBase {
// expctxStat = new BExpressionContext("way");
// *** read the relation file into sets for each processed tag
routesets = new HashMap<String, CompactLongSet>();
routesets = new HashMap<>();
routesetall = new CompactLongSet();
DataInputStream dis = createInStream(relationFileIn);
try {

View file

@ -25,7 +25,7 @@ public class RelationStatistics extends MapCreatorBase {
}
public void process(File relationFileIn) throws Exception {
HashMap<String, long[]> relstats = new HashMap<String, long[]>();
HashMap<String, long[]> relstats = new HashMap<>();
DataInputStream dis = createInStream(relationFileIn);
try {

View file

@ -108,7 +108,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
private void reset() {
minLon = -1;
minLat = -1;
nodesMap = new CompactLongMap<OsmNodeP>();
nodesMap = new CompactLongMap<>();
borderSet = new CompactLongSet();
}
@ -231,7 +231,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
new NodeIterator(this, true).processFile(nodeFile);
// freeze the nodes-map
FrozenLongMap<OsmNodeP> nodesMapFrozen = new FrozenLongMap<OsmNodeP>(nodesMap);
FrozenLongMap<OsmNodeP> nodesMapFrozen = new FrozenLongMap<>(nodesMap);
nodesMap = nodesMapFrozen;
File restrictionFile = fileFromTemplate(wayfile, new File(nodeTilesIn.getParentFile(), "restrictions55"), "rt5");
@ -415,7 +415,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
int nLatSegs = (maxLat - minLat) / 1000000;
// sort the nodes into segments
LazyArrayOfLists<OsmNodeP> seglists = new LazyArrayOfLists<OsmNodeP>(nLonSegs * nLatSegs);
LazyArrayOfLists<OsmNodeP> seglists = new LazyArrayOfLists<>(nLonSegs * nLatSegs);
for (OsmNodeP n : nodesList) {
if (n == null || n.getFirstLink() == null || n.isTransferNode())
continue;
@ -450,7 +450,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
if (seglists.getSize(tileIndex) > 0) {
List<OsmNodeP> nlist = seglists.getList(tileIndex);
LazyArrayOfLists<OsmNodeP> subs = new LazyArrayOfLists<OsmNodeP>(ncaches);
LazyArrayOfLists<OsmNodeP> subs = new LazyArrayOfLists<>(ncaches);
byte[][] subByteArrays = new byte[ncaches][];
for (int ni = 0; ni < nlist.size(); ni++) {
OsmNodeP n = nlist.get(ni);
@ -473,7 +473,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
MicroCache mc = new MicroCache2(size, abBuf2, lonIdxDiv, latIdxDiv, divisor);
// sort via treemap
TreeMap<Integer, OsmNodeP> sortedList = new TreeMap<Integer, OsmNodeP>();
TreeMap<Integer, OsmNodeP> sortedList = new TreeMap<>();
for (OsmNodeP n : subList) {
long longId = n.getIdFromPos();
int shrinkid = mc.shrinkId(longId);