From 04d08c0669b750b2a8cfc3e76c92d2f5075619b7 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sun, 26 Jun 2016 02:30:12 +0100 Subject: [PATCH] Make QueueHandlerFactory final. I don't think there's a good reason to change it without ditching the entire output queue. --- .../parser/irc/outputqueue/OutputQueue.java | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/irc/src/com/dmdirc/parser/irc/outputqueue/OutputQueue.java b/irc/src/com/dmdirc/parser/irc/outputqueue/OutputQueue.java index 3dcfc29..94ea02f 100644 --- a/irc/src/com/dmdirc/parser/irc/outputqueue/OutputQueue.java +++ b/irc/src/com/dmdirc/parser/irc/outputqueue/OutputQueue.java @@ -47,46 +47,40 @@ public class OutputQueue { /** Thread for the sending queue. */ private QueueHandler queueHandler; /** The QueueHandlerFactory for this OutputQueue. */ - private QueueHandlerFactory queueHandlerFactory = PriorityQueueHandler.getFactory(); + private final QueueHandlerFactory queueHandlerFactory; /** - * Set the output stream for this queue. - * - * @param outputStream Output Stream to use. + * Creates a new output queue using the default handler. */ - public void setOutputStream(final OutputStream outputStream) { - this.out = new PrintWriter(outputStream, true); + public OutputQueue() { + this(PriorityQueueHandler.getFactory()); } /** - * Is output queueing enabled? + * Creates a new output queue using a handler from the given factory. * - * @return true if output queueing is enabled. + * @param queueHandlerFactory The factory to use to create {@link QueueHandler}s. */ - public boolean isQueueEnabled() { - return queueEnabled; + public OutputQueue(final QueueHandlerFactory queueHandlerFactory) { + this.queueHandlerFactory = queueHandlerFactory; } /** - * Set the QueueHandlerFactory. - * Changing this will not change an existing QueueHandler unless queueing is - * disabled and reenabled. - * If this is called before the first lien of output is queued then there is - * no need to disable and reenable the queue. + * Set the output stream for this queue. * - * @param factory New QueueHandlerFactory to use. + * @param outputStream Output Stream to use. */ - public void setQueueHandlerFactory(final QueueHandlerFactory factory) { - queueHandlerFactory = factory; + public void setOutputStream(final OutputStream outputStream) { + this.out = new PrintWriter(outputStream, true); } /** - * Get the QueueHandlerFactory. + * Is output queueing enabled? * - * @return The current QueueHandlerFactory. + * @return true if output queueing is enabled. */ - public QueueHandlerFactory getQueueHandlerFactory() { - return queueHandlerFactory; + public boolean isQueueEnabled() { + return queueEnabled; } /**