From d8b766725b20b0adf0853a4ddba7a76b30ba1206 Mon Sep 17 00:00:00 2001 From: Hai Brenner Date: Mon, 4 Jul 2016 15:52:05 +0300 Subject: [PATCH] Removed many compilation warnings by having better handling of Generics types and better JavaDocs --- .../output/AsyncRunnableOutputDevice.java | 18 ++++++++++-------- .../voting/output/NetworkVirtualPrinter.java | 4 +++- .../output/SystemConsoleOutputDevice.java | 6 +++--- .../outputcommands/AuditOutputCommand.java | 4 ++-- .../outputcommands/CancelOutputCommand.java | 4 ++-- .../outputcommands/CastOutputCommand.java | 4 ++-- .../outputcommands/CommitOutputCommand.java | 4 ++-- .../output/outputcommands/OutputCommand.java | 8 +++----- .../ui/uicommands/CastOrAuditUICommand.java | 5 +++-- .../ui/uicommands/ChannelChoiceUICommand.java | 4 ++-- .../ui/uicommands/FatalErrorUICommand.java | 8 ++++---- .../ui/uicommands/RaceVotingUICommand.java | 4 ++-- .../ui/uicommands/StartSessionUICommand.java | 4 ++-- .../voting/ui/uicommands/TickCommand.java | 4 ++-- .../voting/ui/uicommands/UICommand.java | 10 ++++------ .../ui/uicommands/WaitForFinishUICommand.java | 4 ++-- 16 files changed, 48 insertions(+), 47 deletions(-) diff --git a/voting-booth/src/main/java/meerkat/voting/output/AsyncRunnableOutputDevice.java b/voting-booth/src/main/java/meerkat/voting/output/AsyncRunnableOutputDevice.java index 88dde5b..7a856a0 100644 --- a/voting-booth/src/main/java/meerkat/voting/output/AsyncRunnableOutputDevice.java +++ b/voting-booth/src/main/java/meerkat/voting/output/AsyncRunnableOutputDevice.java @@ -5,6 +5,8 @@ import meerkat.protobuf.Voting.BallotSecrets; import meerkat.protobuf.Voting.PlaintextBallot; import meerkat.protobuf.Voting.SignedEncryptedBallot; import meerkat.voting.controller.callbacks.ControllerCallback; +import meerkat.voting.controller.callbacks.OutputDeviceCommitCallback; +import meerkat.voting.controller.callbacks.OutputDeviceFinalizeCallback; import meerkat.voting.output.outputcommands.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,49 +87,49 @@ public abstract class AsyncRunnableOutputDevice implements BallotOutputDevice, R SignedEncryptedBallot signedEncryptedBallot, FutureCallback callback) { logger.debug("Output interface call to commit to ballot"); - queue.add(new CommitOutputCommand(plaintextBallot, signedEncryptedBallot, (ControllerCallback)callback)); + queue.add(new CommitOutputCommand(plaintextBallot, signedEncryptedBallot, (OutputDeviceCommitCallback)callback)); } @Override public void audit(BallotSecrets ballotSecrets, FutureCallback callback) { logger.debug("an interface call to audit"); - queue.add(new AuditOutputCommand(ballotSecrets, (ControllerCallback)callback)); + queue.add(new AuditOutputCommand(ballotSecrets, (OutputDeviceFinalizeCallback)callback)); } @Override public void castBallot(FutureCallback callback) { logger.debug("an interface call to cast ballot"); - queue.add(new CastOutputCommand((ControllerCallback)callback)); + queue.add(new CastOutputCommand((OutputDeviceFinalizeCallback)callback)); } @Override public void cancelBallot(FutureCallback callback) { logger.debug("an interface call to cancel the output"); - queue.add(new CancelOutputCommand((ControllerCallback)callback)); + queue.add(new CancelOutputCommand((ControllerCallback)callback)); } /** * This method should be filled by an extending class. It should have the details of how to commit to a ballot - * @param command + * @param command a CommitOutputCommand with the details and the callback */ abstract void doCommitToBallot(CommitOutputCommand command); /** * This method should be filled by an extending class. It should have the details of how to audit the ballot - * @param command + * @param command a AuditOutputCommand with the details and the callback */ abstract void doAudit(AuditOutputCommand command); /** * This method should be filled by an extending class. It should have the details of how to cast the ballot - * @param command + * @param command a CastOutputCommand with the details and the callback */ abstract void doCastBallot(CastOutputCommand command); /** * This method should be filled by an extending class. It should have the details of how to cancel the ballot output - * @param command + * @param command a CancelOutputCommand with the details and the callback */ abstract void doCancel(CancelOutputCommand command); diff --git a/voting-booth/src/main/java/meerkat/voting/output/NetworkVirtualPrinter.java b/voting-booth/src/main/java/meerkat/voting/output/NetworkVirtualPrinter.java index 05be623..6ec2583 100644 --- a/voting-booth/src/main/java/meerkat/voting/output/NetworkVirtualPrinter.java +++ b/voting-booth/src/main/java/meerkat/voting/output/NetworkVirtualPrinter.java @@ -53,6 +53,7 @@ public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice { /** * The NetworkVirtualPrinter actually does nothing for auditing. + * @param command a AuditOutputCommand with the details and the callback */ public void doAudit(AuditOutputCommand command) { logger.debug("entered method doAudit"); @@ -63,7 +64,7 @@ public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice { /** * This is where the magic happens. The signed encrypted ballot is transmitted over the wire - * @param command + * @param command a CastOutputCommand with the details and the callback */ public void doCastBallot(CastOutputCommand command) { logger.debug("entered method doCastBallot"); @@ -87,6 +88,7 @@ public class NetworkVirtualPrinter extends AsyncRunnableOutputDevice { /** * The NetworkVirtualPrinter actually does nothing for canceling. + * @param command a CancelOutputCommand with the callback */ public void doCancel(CancelOutputCommand command) { logger.debug("entered method doCancel"); diff --git a/voting-booth/src/main/java/meerkat/voting/output/SystemConsoleOutputDevice.java b/voting-booth/src/main/java/meerkat/voting/output/SystemConsoleOutputDevice.java index c07d8df..daf468e 100644 --- a/voting-booth/src/main/java/meerkat/voting/output/SystemConsoleOutputDevice.java +++ b/voting-booth/src/main/java/meerkat/voting/output/SystemConsoleOutputDevice.java @@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory; */ public class SystemConsoleOutputDevice extends AsyncRunnableOutputDevice { - private static final Logger logger = LoggerFactory.getLogger(SystemConsoleOutputDevice.class);; + private static final Logger logger = LoggerFactory.getLogger(SystemConsoleOutputDevice.class); public SystemConsoleOutputDevice () { super(); @@ -60,7 +60,7 @@ public class SystemConsoleOutputDevice extends AsyncRunnableOutputDevice { /** * Casting the ballot (actually does nothing new) - * @param command + * @param command a CastOutputCommand with the details and the callback */ public void doCastBallot(CastOutputCommand command) { logger.debug("entered method doCastBallot"); @@ -71,7 +71,7 @@ public class SystemConsoleOutputDevice extends AsyncRunnableOutputDevice { /** * Canceling the ballot (actually does nothing new) - * @param command + * @param command a CancelOutputCommand with the details and the callback */ public void doCancel(CancelOutputCommand command) { logger.debug("entered method doCancel"); diff --git a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/AuditOutputCommand.java b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/AuditOutputCommand.java index 564fb06..0d4d6ea 100644 --- a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/AuditOutputCommand.java +++ b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/AuditOutputCommand.java @@ -6,11 +6,11 @@ import meerkat.voting.controller.callbacks.ControllerCallback; /** * This OutputCommand supplies the necessary details for outputting Audit information */ -public class AuditOutputCommand extends OutputCommand { +public class AuditOutputCommand extends OutputCommand { private final BallotSecrets ballotSecrets; - public AuditOutputCommand(BallotSecrets ballotSecrets, ControllerCallback callback) { + public AuditOutputCommand(BallotSecrets ballotSecrets, ControllerCallback callback) { super(callback); this.ballotSecrets = ballotSecrets; } diff --git a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CancelOutputCommand.java b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CancelOutputCommand.java index 26a0388..88fe03f 100644 --- a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CancelOutputCommand.java +++ b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CancelOutputCommand.java @@ -5,9 +5,9 @@ import meerkat.voting.controller.callbacks.ControllerCallback; /** * This OutputCommand signals the output-device that it should Cancel the rest of the ballot output */ -public class CancelOutputCommand extends OutputCommand { +public class CancelOutputCommand extends OutputCommand { - public CancelOutputCommand(ControllerCallback callback) { + public CancelOutputCommand(ControllerCallback callback) { super(callback); } diff --git a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CastOutputCommand.java b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CastOutputCommand.java index a89eb1b..5098cd5 100644 --- a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CastOutputCommand.java +++ b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CastOutputCommand.java @@ -5,9 +5,9 @@ import meerkat.voting.controller.callbacks.ControllerCallback; /** * This OutputCommand signals the output-device that the voter wishes to Cast the ballot */ -public class CastOutputCommand extends OutputCommand { +public class CastOutputCommand extends OutputCommand { - public CastOutputCommand(ControllerCallback callback) { + public CastOutputCommand(ControllerCallback callback) { super(callback); } diff --git a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CommitOutputCommand.java b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CommitOutputCommand.java index a3bd9ac..5bec550 100644 --- a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CommitOutputCommand.java +++ b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/CommitOutputCommand.java @@ -6,14 +6,14 @@ import meerkat.voting.controller.callbacks.ControllerCallback; /** * This OutputCommand supplies the necessary details for outputting a commit to the ballot */ -public class CommitOutputCommand extends OutputCommand { +public class CommitOutputCommand extends OutputCommand { private final PlaintextBallot plaintextBallot; private final SignedEncryptedBallot signedEncryptedBallot; public CommitOutputCommand(PlaintextBallot plaintextBallot, SignedEncryptedBallot signedEncryptedBallot, - ControllerCallback callback) { + ControllerCallback callback) { super(callback); this.plaintextBallot = plaintextBallot; this.signedEncryptedBallot = signedEncryptedBallot; diff --git a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/OutputCommand.java b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/OutputCommand.java index 342c314..59f5ebc 100644 --- a/voting-booth/src/main/java/meerkat/voting/output/outputcommands/OutputCommand.java +++ b/voting-booth/src/main/java/meerkat/voting/output/outputcommands/OutputCommand.java @@ -2,19 +2,17 @@ package meerkat.voting.output.outputcommands; import meerkat.voting.controller.callbacks.ControllerCallback; -//TODO: make this class generic - /** * Base class for the commands to put in the output-device queue */ -public abstract class OutputCommand { +public abstract class OutputCommand { protected final ControllerCallback callback; - protected OutputCommand(ControllerCallback callback) { + protected OutputCommand(ControllerCallback callback) { this.callback = callback; } - public ControllerCallback getCallback () { + public ControllerCallback getCallback () { return this.callback; } } diff --git a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/CastOrAuditUICommand.java b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/CastOrAuditUICommand.java index 6e18b0b..583a4a2 100644 --- a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/CastOrAuditUICommand.java +++ b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/CastOrAuditUICommand.java @@ -1,12 +1,13 @@ package meerkat.voting.ui.uicommands; import meerkat.voting.controller.callbacks.*; +import meerkat.voting.ui.VotingBoothUI.FinalizeBallotChoice; /** * This command signals the UI that the voter should now choose whether to Cast or Audit the ballot */ -public class CastOrAuditUICommand extends UICommand { - public CastOrAuditUICommand(ControllerCallback callback) { +public class CastOrAuditUICommand extends UICommand { + public CastOrAuditUICommand(ControllerCallback callback) { super(callback); } } diff --git a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/ChannelChoiceUICommand.java b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/ChannelChoiceUICommand.java index f225ea6..185e255 100644 --- a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/ChannelChoiceUICommand.java +++ b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/ChannelChoiceUICommand.java @@ -8,11 +8,11 @@ import java.util.List; /** * This command signals the UI to present channel choice questions to the voter and send back the answers */ -public class ChannelChoiceUICommand extends UICommand { +public class ChannelChoiceUICommand extends UICommand> { private final List questions; - public ChannelChoiceUICommand(List questions, ControllerCallback callback) + public ChannelChoiceUICommand(List questions, ControllerCallback> callback) { super(callback); this.questions = questions; diff --git a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/FatalErrorUICommand.java b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/FatalErrorUICommand.java index 1d47700..98af0e4 100644 --- a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/FatalErrorUICommand.java +++ b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/FatalErrorUICommand.java @@ -6,12 +6,12 @@ import meerkat.voting.controller.callbacks.*; /** * This command signals the UI that a fatal error occurred and it should notify the voter */ -public class FatalErrorUICommand extends UICommand { +public class FatalErrorUICommand extends UICommand { private final UIElement errorMessage; private final UIElement[] buttonLabels; - public FatalErrorUICommand(UIElement errorMessage, UIElement[] buttonLabels, ControllerCallback callback) + public FatalErrorUICommand(UIElement errorMessage, UIElement[] buttonLabels, ControllerCallback callback) { super(callback); this.errorMessage = errorMessage; @@ -19,10 +19,10 @@ public class FatalErrorUICommand extends UICommand { } public UIElement getErrorMessage() { - return this.errorMessage; + return errorMessage; } public UIElement[] getButtonLabels() { - return this.getButtonLabels(); + return buttonLabels; } } diff --git a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/RaceVotingUICommand.java b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/RaceVotingUICommand.java index 6b181e6..9b329bc 100644 --- a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/RaceVotingUICommand.java +++ b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/RaceVotingUICommand.java @@ -8,11 +8,11 @@ import java.util.List; /** * This command signals the UI to present the race voting questions to the voter */ -public class RaceVotingUICommand extends UICommand { +public class RaceVotingUICommand extends UICommand> { private final List questions; - public RaceVotingUICommand(List questions, ControllerCallback callback) + public RaceVotingUICommand(List questions, ControllerCallback> callback) { super(callback); this.questions = questions; diff --git a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/StartSessionUICommand.java b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/StartSessionUICommand.java index d99313e..b40bb5d 100644 --- a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/StartSessionUICommand.java +++ b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/StartSessionUICommand.java @@ -5,9 +5,9 @@ import meerkat.voting.controller.callbacks.*; /** * This command signals the UI to present a new session to a voter */ -public class StartSessionUICommand extends UICommand { +public class StartSessionUICommand extends UICommand { - public StartSessionUICommand(ControllerCallback callback) { + public StartSessionUICommand(ControllerCallback callback) { super(callback); } } diff --git a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/TickCommand.java b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/TickCommand.java index 2e2d033..e9bb2b7 100644 --- a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/TickCommand.java +++ b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/TickCommand.java @@ -6,9 +6,9 @@ import meerkat.voting.controller.callbacks.*; * This is a special UI command which just points out that a tick of the clock occurred * (so a progress bar can advance while waiting) */ -public class TickCommand extends UICommand { +public class TickCommand extends UICommand { - public TickCommand(ControllerCallback callback) { + public TickCommand(ControllerCallback callback) { super(callback); assert null == callback; } diff --git a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/UICommand.java b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/UICommand.java index 4ac47a8..e579133 100644 --- a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/UICommand.java +++ b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/UICommand.java @@ -2,19 +2,17 @@ package meerkat.voting.ui.uicommands; import meerkat.voting.controller.callbacks.*; -//TODO: make this class generic - /** * Base class for the commands to put in the UI queue */ -public abstract class UICommand { - protected final ControllerCallback callback; +public abstract class UICommand { + protected final ControllerCallback callback; - protected UICommand(ControllerCallback callback) { + protected UICommand(ControllerCallback callback) { this.callback = callback; } - public ControllerCallback getCallback () { + public ControllerCallback getCallback () { return this.callback; } } diff --git a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/WaitForFinishUICommand.java b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/WaitForFinishUICommand.java index 7006014..5e5d504 100644 --- a/voting-booth/src/main/java/meerkat/voting/ui/uicommands/WaitForFinishUICommand.java +++ b/voting-booth/src/main/java/meerkat/voting/ui/uicommands/WaitForFinishUICommand.java @@ -6,11 +6,11 @@ import meerkat.voting.controller.callbacks.*; /** * This command signals the UI to wait with an appropriate message until a new command replaces this state */ -public class WaitForFinishUICommand extends UICommand { +public class WaitForFinishUICommand extends UICommand { private final UIElement message; - public WaitForFinishUICommand(UIElement message, ControllerCallback callback) + public WaitForFinishUICommand(UIElement message, ControllerCallback callback) { super(callback); this.message = message;