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

@ -8,8 +8,8 @@ import java.util.ArrayList;
import java.util.List;
public class Area {
private List<Polygon> poslist = new ArrayList<Polygon>();
private List<Polygon> neglist = new ArrayList<Polygon>();
private List<Polygon> poslist = new ArrayList<>();
private List<Polygon> neglist = new ArrayList<>();
public static void main(String[] args) throws IOException {
Area a = new Area(new File(args[0]));

View file

@ -63,7 +63,7 @@ public class BRouter {
maxRunningTime = Integer.parseInt(sMaxRunningTime) * 1000;
}
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
List<OsmNodeNamed> wplist = new ArrayList<>();
wplist.add(from);
wplist.add(to);
@ -83,7 +83,7 @@ public class BRouter {
System.out.println("usage: java -jar brouter.jar <segmentdir> <lon-from> <lat-from> <lon-to> <lat-to> <profile>");
return;
}
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
List<OsmNodeNamed> wplist = new ArrayList<>();
wplist.add(readPosition(args, 1, "from"));
RoutingEngine re = null;
if ("seed".equals(args[3])) {

View file

@ -5,7 +5,7 @@ import java.util.Map;
public class IpAccessMonitor {
private static Object sync = new Object();
private static Map<String, Long> ipAccess = new HashMap<String, Long>();
private static Map<String, Long> ipAccess = new HashMap<>();
private static long MAX_IDLE = 900000; // 15 minutes
private static long CLEANUP_INTERVAL = 10000; // 10 seconds
private static long lastCleanup;
@ -31,7 +31,7 @@ public class IpAccessMonitor {
}
private static void cleanup(long t) {
HashMap<String, Long> newMap = new HashMap<String, Long>(ipAccess.size());
HashMap<String, Long> newMap = new HashMap<>(ipAccess.size());
for (Map.Entry<String, Long> e : ipAccess.entrySet()) {
if (t - e.getValue().longValue() <= MAX_IDLE) {
newMap.put(e.getKey(), e.getValue());

View file

@ -15,7 +15,7 @@ public class Polygon {
private int maxy = Integer.MIN_VALUE;
public Polygon(BufferedReader br) throws IOException {
ArrayList<String> lines = new ArrayList<String>();
ArrayList<String> lines = new ArrayList<>();
for (; ; ) {
String line = br.readLine();

View file

@ -199,7 +199,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
rc.forceUseStartDirection = true;
} else if (e.getKey().startsWith("profile:")) {
if (rc.keyValues == null) {
rc.keyValues = new HashMap<String, String>();
rc.keyValues = new HashMap<>();
}
rc.keyValues.put(e.getKey().substring(8), e.getValue());
} else if (e.getKey().equals("straight")) {
@ -294,7 +294,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
ProfileCache.setSize(2 * maxthreads);
PriorityQueue<RouteServer> threadQueue = new PriorityQueue<RouteServer>();
PriorityQueue<RouteServer> threadQueue = new PriorityQueue<>();
ServerSocket serverSocket = args.length > 5 ? new ServerSocket(Integer.parseInt(args[3]), 100, InetAddress.getByName(args[5])) : new ServerSocket(Integer.parseInt(args[3]));
@ -359,7 +359,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
private static Map<String, String> getUrlParams(String url) throws UnsupportedEncodingException {
HashMap<String, String> params = new HashMap<String, String>();
HashMap<String, String> params = new HashMap<>();
String decoded = URLDecoder.decode(url, "UTF-8");
StringTokenizer tk = new StringTokenizer(decoded, "?&");
while (tk.hasMoreTokens()) {

View file

@ -244,7 +244,7 @@ public class SuspectManager extends Thread {
bw.write("<table>\n");
File countryParent = new File("worldpolys" + country);
File[] files = countryParent.listFiles();
TreeSet<String> names = new TreeSet<String>();
TreeSet<String> names = new TreeSet<>();
for (File f : files) {
String name = f.getName();
if (name.endsWith(".poly")) {
@ -580,7 +580,7 @@ public class SuspectManager extends Thread {
}
}
private static Map<String, SuspectList> allSuspectsMap = new HashMap<String, SuspectList>();
private static Map<String, SuspectList> allSuspectsMap = new HashMap<>();
private static SuspectList getDailySuspectsIfLoaded() throws IOException {
synchronized (allSuspectsMap) {

View file

@ -51,7 +51,7 @@ public class ProfileUploadHandler {
fileWriter.flush();
//System.out.println("data: |" + sw.toString() + "|");
Map<String, String> responseData = new HashMap<String, String>();
Map<String, String> responseData = new HashMap<>();
responseData.put("profileid", CUSTOM_PREFIX + id);
validateProfile(id, responseData);

View file

@ -94,7 +94,7 @@ public class ServerHandler extends RequestHandler {
if (coords.length < 2)
throw new IllegalArgumentException("we need two lat/lon points at least!");
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
List<OsmNodeNamed> wplist = new ArrayList<>();
for (int i = 0; i < coords.length; i++) {
String[] lonLat = coords[i].split(",");
if (lonLat.length < 2)
@ -213,7 +213,7 @@ public class ServerHandler extends RequestHandler {
String[] lonLatNameList = pois.split("\\|");
List<OsmNodeNamed> poisList = new ArrayList<OsmNodeNamed>();
List<OsmNodeNamed> poisList = new ArrayList<>();
for (int i = 0; i < lonLatNameList.length; i++) {
String[] lonLatName = lonLatNameList[i].split(",");
@ -237,7 +237,7 @@ public class ServerHandler extends RequestHandler {
String[] lonLatRadList = nogos.split("\\|");
List<OsmNodeNamed> nogoList = new ArrayList<OsmNodeNamed>();
List<OsmNodeNamed> nogoList = new ArrayList<>();
for (int i = 0; i < lonLatRadList.length; i++) {
String[] lonLatRad = lonLatRadList[i].split(",");
String nogoWeight = "NaN";
@ -266,7 +266,7 @@ public class ServerHandler extends RequestHandler {
}
private List<OsmNodeNamed> readNogoPolygons() {
List<OsmNodeNamed> result = new ArrayList<OsmNodeNamed>();
List<OsmNodeNamed> result = new ArrayList<>();
parseNogoPolygons(params.get("polylines"), result, false);
parseNogoPolygons(params.get("polygons"), result, true);
return result.size() > 0 ? result : null;