Fix PlayerKeyValueRepository's exception and return types
This commit is contained in:
parent
abb2729c0e
commit
825839d853
@ -4,11 +4,15 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
/**
|
||||
* A SQL-backed repository supporting {@link String} keys and
|
||||
@ -110,7 +114,7 @@ public class PlayerKeyValueRepository<V>
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -141,7 +145,7 @@ public class PlayerKeyValueRepository<V>
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -155,7 +159,7 @@ public class PlayerKeyValueRepository<V>
|
||||
* @return a {@link CompletableFuture} whose value indicates
|
||||
* success or failure
|
||||
*/
|
||||
public CompletableFuture<Boolean> put(UUID uuid, String key, V value)
|
||||
public CompletableFuture<Void> put(UUID uuid, String key, V value)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
@ -166,12 +170,12 @@ public class PlayerKeyValueRepository<V>
|
||||
_mapper._serializer.write(stmt, 2, value);
|
||||
stmt.setString(3, uuid.toString());
|
||||
stmt.executeUpdate();
|
||||
return true;
|
||||
return null;
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -206,7 +210,7 @@ public class PlayerKeyValueRepository<V>
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -219,7 +223,7 @@ public class PlayerKeyValueRepository<V>
|
||||
* @return a {@link CompletableFuture} whose value indicates
|
||||
* success or failure
|
||||
*/
|
||||
public CompletableFuture<Boolean> remove(UUID uuid, String key)
|
||||
public CompletableFuture<Void> remove(UUID uuid, String key)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
@ -229,12 +233,12 @@ public class PlayerKeyValueRepository<V>
|
||||
stmt.setString(1, uuid.toString());
|
||||
stmt.setString(2, key);
|
||||
stmt.executeUpdate();
|
||||
return true;
|
||||
return null;
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -246,7 +250,7 @@ public class PlayerKeyValueRepository<V>
|
||||
* @return a {@link CompletableFuture} whose value indicates
|
||||
* success or failure
|
||||
*/
|
||||
public CompletableFuture<Boolean> removeAll(UUID uuid)
|
||||
public CompletableFuture<Void> removeAll(UUID uuid)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
@ -255,12 +259,12 @@ public class PlayerKeyValueRepository<V>
|
||||
PreparedStatement stmt = conn.prepareStatement("DELETE FROM " + _tableName + " WHERE accountId=(SELECT id FROM accounts WHERE uuid=?)");
|
||||
stmt.setString(1, uuid.toString());
|
||||
stmt.executeUpdate();
|
||||
return true;
|
||||
return null;
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user