Removed many compilation warnings by having better handling of Generics types and better JavaDocs
parent
218677fd96
commit
d8b766725b
|
@ -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<Void> 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<Void> 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<Void> 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<Void> callback) {
|
||||
logger.debug("an interface call to cancel the output");
|
||||
queue.add(new CancelOutputCommand((ControllerCallback)callback));
|
||||
queue.add(new CancelOutputCommand((ControllerCallback<Void>)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);
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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<Void> {
|
||||
|
||||
private final BallotSecrets ballotSecrets;
|
||||
|
||||
public AuditOutputCommand(BallotSecrets ballotSecrets, ControllerCallback callback) {
|
||||
public AuditOutputCommand(BallotSecrets ballotSecrets, ControllerCallback<Void> callback) {
|
||||
super(callback);
|
||||
this.ballotSecrets = ballotSecrets;
|
||||
}
|
||||
|
|
|
@ -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<Void> {
|
||||
|
||||
public CancelOutputCommand(ControllerCallback callback) {
|
||||
public CancelOutputCommand(ControllerCallback<Void> callback) {
|
||||
super(callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Void> {
|
||||
|
||||
public CastOutputCommand(ControllerCallback callback) {
|
||||
public CastOutputCommand(ControllerCallback<Void> callback) {
|
||||
super(callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Void> {
|
||||
|
||||
private final PlaintextBallot plaintextBallot;
|
||||
private final SignedEncryptedBallot signedEncryptedBallot;
|
||||
|
||||
public CommitOutputCommand(PlaintextBallot plaintextBallot,
|
||||
SignedEncryptedBallot signedEncryptedBallot,
|
||||
ControllerCallback callback) {
|
||||
ControllerCallback<Void> callback) {
|
||||
super(callback);
|
||||
this.plaintextBallot = plaintextBallot;
|
||||
this.signedEncryptedBallot = signedEncryptedBallot;
|
||||
|
|
|
@ -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<T> {
|
||||
protected final ControllerCallback callback;
|
||||
|
||||
protected OutputCommand(ControllerCallback callback) {
|
||||
protected OutputCommand(ControllerCallback<T> callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public ControllerCallback getCallback () {
|
||||
public ControllerCallback<T> getCallback () {
|
||||
return this.callback;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<FinalizeBallotChoice> {
|
||||
public CastOrAuditUICommand(ControllerCallback<FinalizeBallotChoice> callback) {
|
||||
super(callback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<List<BallotAnswer>> {
|
||||
|
||||
private final List<BallotQuestion> questions;
|
||||
|
||||
public ChannelChoiceUICommand(List<BallotQuestion> questions, ControllerCallback callback)
|
||||
public ChannelChoiceUICommand(List<BallotQuestion> questions, ControllerCallback<List<BallotAnswer>> callback)
|
||||
{
|
||||
super(callback);
|
||||
this.questions = questions;
|
||||
|
|
|
@ -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<Integer> {
|
||||
|
||||
private final UIElement errorMessage;
|
||||
private final UIElement[] buttonLabels;
|
||||
|
||||
public FatalErrorUICommand(UIElement errorMessage, UIElement[] buttonLabels, ControllerCallback callback)
|
||||
public FatalErrorUICommand(UIElement errorMessage, UIElement[] buttonLabels, ControllerCallback<Integer> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<List<BallotAnswer>> {
|
||||
|
||||
private final List<BallotQuestion> questions;
|
||||
|
||||
public RaceVotingUICommand(List<BallotQuestion> questions, ControllerCallback callback)
|
||||
public RaceVotingUICommand(List<BallotQuestion> questions, ControllerCallback<List<BallotAnswer>> callback)
|
||||
{
|
||||
super(callback);
|
||||
this.questions = questions;
|
||||
|
|
|
@ -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<Void> {
|
||||
|
||||
public StartSessionUICommand(ControllerCallback callback) {
|
||||
public StartSessionUICommand(ControllerCallback<Void> callback) {
|
||||
super(callback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Void> {
|
||||
|
||||
public TickCommand(ControllerCallback callback) {
|
||||
public TickCommand(ControllerCallback<Void> callback) {
|
||||
super(callback);
|
||||
assert null == callback;
|
||||
}
|
||||
|
|
|
@ -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<T> {
|
||||
protected final ControllerCallback<T> callback;
|
||||
|
||||
protected UICommand(ControllerCallback callback) {
|
||||
protected UICommand(ControllerCallback<T> callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public ControllerCallback getCallback () {
|
||||
public ControllerCallback<T> getCallback () {
|
||||
return this.callback;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Void> {
|
||||
|
||||
private final UIElement message;
|
||||
|
||||
public WaitForFinishUICommand(UIElement message, ControllerCallback callback)
|
||||
public WaitForFinishUICommand(UIElement message, ControllerCallback<Void> callback)
|
||||
{
|
||||
super(callback);
|
||||
this.message = message;
|
||||
|
|
Loading…
Reference in New Issue