Commit 6d370a64 authored by bogdanbear's avatar bogdanbear

Forcefully removed some warnings in the networks package, since the unchecked...

Forcefully removed some warnings in the networks package, since the unchecked casts can never occur without a compile error.
parent 214c6870
......@@ -6,15 +6,13 @@ import java.util.concurrent.LinkedBlockingDeque;
/**
* Created by bogdanbear on 21/11/2015.
*/
/**
* This is the class we are going to use for transparency over the network
* incomingEvents will be used as the single event queue;
* receive event behaves in the exact same way
* In the next version we are going to remove sendEventOnServer() and receiveEventOnServer()
* since they are not architecturally sound.
*/
@SuppressWarnings("unchecked")
public class LocalConnection<E extends NetworkObject> extends NetworkConnection<E> {
protected BlockingDeque<NetworkObject> outgoingEvents;
......@@ -65,7 +63,7 @@ public class LocalConnection<E extends NetworkObject> extends NetworkConnection<
*/
@Override
public E receiveEvent(boolean blocking) {
if (blocking == false) {
if (!blocking) {
try {
return (E) incomingEvents.removeFirst();
} catch (NoSuchElementException e) {
......
......@@ -17,13 +17,14 @@ import java.util.logging.Logger;
* Created by bogdanbear on 20/11/2015.
* E-Element is the generic type used by Java.Collections
*/
@SuppressWarnings("unchecked")
public abstract class NetworkConnection<E extends NetworkObject> {
protected BlockingDeque<NetworkObject> incomingEvents=new LinkedBlockingDeque<>();
protected static Logger LOGGER = new Logging().getLogger();
/**
* Function for testing whether an object is Serializable or not
* @param event
* @param event the argument must be a networkobject
* @return a boolean representing whether our object is truly serializable or not
*/
public boolean notSerializable(E event)
......@@ -74,8 +75,9 @@ public abstract class NetworkConnection<E extends NetworkObject> {
* @return a new event or null if there is no new event
*/
//making this method synchronized would be a grave error, since incoming events might induce a block inside this method
@SuppressWarnings("unchecked")
public E receiveEvent(boolean blocking) {
if (blocking==false) {
if (!blocking) {
try {
return (E)incomingEvents.removeFirst();
} catch (NoSuchElementException e) {
......
......@@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals;
* The second function will do the opposite.
* Finally, we will test initiateConnectionEnd (TODO)
*/
@SuppressWarnings("unchecked")
public class LocalConnectionTest{
NetworkConnection[] localConnections= LocalConnection.initiate();
private NetworkConnection serverConnection = localConnections[0];
......
......@@ -18,6 +18,7 @@ import java.net.Socket;
* Class for JUnits test for the class ServerConnection.
* Created by mymi on 20/12/15.
*/
@SuppressWarnings("unchecked")
public class ServerConnectionTest{
private static ServerConnection server;
private ObjectForTest e = new ObjectForTest("Server test ok");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment