aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/ConnectionManager.java8
-rw-r--r--src/org/traccar/database/DataManager.java6
-rw-r--r--src/org/traccar/database/PermissionsManager.java4
-rw-r--r--src/org/traccar/database/QueryBuilder.java36
4 files changed, 20 insertions, 34 deletions
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index eb22379da..0d357a41c 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -31,9 +31,9 @@ import org.traccar.model.Position;
public class ConnectionManager {
- private Map<String, ActiveDevice> activeDevices = new HashMap<String, ActiveDevice>();
- private final Map<Long, Position> positions = new HashMap<Long, Position>();
- private final Map<Long, Set<DataCacheListener>> listeners = new HashMap<Long, Set<DataCacheListener>>();
+ private Map<String, ActiveDevice> activeDevices = new HashMap<>();
+ private final Map<Long, Position> positions = new HashMap<>();
+ private final Map<Long, Set<DataCacheListener>> listeners = new HashMap<>();
public void init(DataManager dataManager) {
try {
@@ -70,7 +70,7 @@ public class ConnectionManager {
public synchronized Collection<Position> getInitialState(Collection<Long> devices) {
- List<Position> result = new LinkedList<Position>();
+ List<Position> result = new LinkedList<>();
for (long device : devices) {
if (positions.containsKey(device)) {
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 959602512..48f3228ce 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -50,7 +50,7 @@ public class DataManager implements IdentityManager {
private DataSource dataSource;
- private final Map<String, Device> devices = new HashMap<String, Device>();
+ private final Map<String, Device> devices = new HashMap<>();
private long devicesLastUpdate;
private final long devicesRefreshDelay;
@@ -200,9 +200,7 @@ public class DataManager implements IdentityManager {
updateLatestPosition(position);
- } catch (SQLException error) {
- Log.warning(error);
- } catch (ParseException error) {
+ } catch (SQLException | ParseException error) {
Log.warning(error);
}
}
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 683f54cb4..40783ad98 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -28,9 +28,9 @@ import org.traccar.model.User;
public class PermissionsManager {
- private final Map<Long, User> users = new HashMap<Long, User>();
+ private final Map<Long, User> users = new HashMap<>();
- private final Map<Long, Set<Long>> permissions = new HashMap<Long, Set<Long>>();
+ private final Map<Long, Set<Long>> permissions = new HashMap<>();
private Set<Long> getNotNull(long userId) {
if (!permissions.containsKey(userId)) {
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java
index 88183f525..17165db82 100644
--- a/src/org/traccar/database/QueryBuilder.java
+++ b/src/org/traccar/database/QueryBuilder.java
@@ -36,7 +36,7 @@ import org.traccar.model.Factory;
public class QueryBuilder {
- private final Map<String, List<Integer>> indexMap = new HashMap<String, List<Integer>>();
+ private final Map<String, List<Integer>> indexMap = new HashMap<>();
private Connection connection;
private PreparedStatement statement;
private final String query;
@@ -106,7 +106,7 @@ public class QueryBuilder {
// Add to list
List<Integer> indexList = paramMap.get(name);
if (indexList == null) {
- indexList = new LinkedList<Integer>();
+ indexList = new LinkedList<>();
paramMap.put(name, indexList);
}
indexList.add(index);
@@ -133,7 +133,7 @@ public class QueryBuilder {
name = name.toLowerCase();
List<Integer> result = indexMap.get(name);
if (result == null) {
- result = new LinkedList<Integer>();
+ result = new LinkedList<>();
}
return result;
}
@@ -264,8 +264,7 @@ public class QueryBuilder {
} else if (method.getReturnType().equals(byte[].class)) {
setBytes(name, (byte[]) method.invoke(object));
}
- } catch (IllegalAccessException error) {
- } catch (InvocationTargetException error) {
+ } catch (IllegalAccessException | InvocationTargetException error) {
}
}
}
@@ -293,13 +292,11 @@ public class QueryBuilder {
try {
- ResultSet resultSet = statement.executeQuery();
-
- try {
+ try (ResultSet resultSet = statement.executeQuery()) {
ResultSetMetaData resultMetaData = resultSet.getMetaData();
- List<ResultSetProcessor<T>> processors = new LinkedList<ResultSetProcessor<T>>();
+ List<ResultSetProcessor<T>> processors = new LinkedList<>();
Method[] methods = prototype.getClass().getMethods();
@@ -328,8 +325,7 @@ public class QueryBuilder {
public void process(T object, ResultSet resultSet) throws SQLException {
try {
method.invoke(object, resultSet.getBoolean(name));
- } catch (IllegalAccessException error) {
- } catch (InvocationTargetException error) {
+ } catch (IllegalAccessException | InvocationTargetException error) {
}
}
});
@@ -339,8 +335,7 @@ public class QueryBuilder {
public void process(T object, ResultSet resultSet) throws SQLException {
try {
method.invoke(object, resultSet.getInt(name));
- } catch (IllegalAccessException error) {
- } catch (InvocationTargetException error) {
+ } catch (IllegalAccessException | InvocationTargetException error) {
}
}
});
@@ -350,8 +345,7 @@ public class QueryBuilder {
public void process(T object, ResultSet resultSet) throws SQLException {
try {
method.invoke(object, resultSet.getLong(name));
- } catch (IllegalAccessException error) {
- } catch (InvocationTargetException error) {
+ } catch (IllegalAccessException | InvocationTargetException error) {
}
}
});
@@ -361,8 +355,7 @@ public class QueryBuilder {
public void process(T object, ResultSet resultSet) throws SQLException {
try {
method.invoke(object, resultSet.getDouble(name));
- } catch (IllegalAccessException error) {
- } catch (InvocationTargetException error) {
+ } catch (IllegalAccessException | InvocationTargetException error) {
}
}
});
@@ -372,8 +365,7 @@ public class QueryBuilder {
public void process(T object, ResultSet resultSet) throws SQLException {
try {
method.invoke(object, resultSet.getString(name));
- } catch (IllegalAccessException error) {
- } catch (InvocationTargetException error) {
+ } catch (IllegalAccessException | InvocationTargetException error) {
}
}
});
@@ -383,8 +375,7 @@ public class QueryBuilder {
public void process(T object, ResultSet resultSet) throws SQLException {
try {
method.invoke(object, new Date(resultSet.getTimestamp(name).getTime()));
- } catch (IllegalAccessException error) {
- } catch (InvocationTargetException error) {
+ } catch (IllegalAccessException | InvocationTargetException error) {
}
}
});
@@ -399,9 +390,6 @@ public class QueryBuilder {
}
result.add(object);
}
-
- } finally {
- resultSet.close();
}
} finally {