From f983bc3f74b055378dd5c7f873430ee27b20ffbb Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Tue, 26 Dec 2017 01:18:36 +0100 Subject: [PATCH] Improved code. --- src/org/april/hebdobot/cli/HebdobotCLI.java | 2 +- src/org/april/hebdobot/model/UserAliases.java | 13 ++++++- .../april/hebdobot/review/MessageList.java | 37 +++++++++++++++++++ src/org/april/hebdobot/review/Review.java | 11 +++--- 4 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 src/org/april/hebdobot/review/MessageList.java diff --git a/src/org/april/hebdobot/cli/HebdobotCLI.java b/src/org/april/hebdobot/cli/HebdobotCLI.java index 678b160..bee6072 100644 --- a/src/org/april/hebdobot/cli/HebdobotCLI.java +++ b/src/org/april/hebdobot/cli/HebdobotCLI.java @@ -137,8 +137,8 @@ public class HebdobotCLI logger.info("Aliases file loading… ({}).", aliasFile.getAbsolutePath()); UserAliases aliases = new UserAliases(aliasFile); logger.info("Aliases file loaded (" + aliases.size() + " aliases)."); + logger.info("Alias liste:\n" + aliases.toString()); - System.exit(0); if (config.isValid()) { logger.info("Bot configuring…"); diff --git a/src/org/april/hebdobot/model/UserAliases.java b/src/org/april/hebdobot/model/UserAliases.java index 41fcd6c..b59d0d5 100644 --- a/src/org/april/hebdobot/model/UserAliases.java +++ b/src/org/april/hebdobot/model/UserAliases.java @@ -91,6 +91,17 @@ public class UserAliases extends HashMap } } + /** + * Instantiates a new user aliases. + * + * @param source + * the source + */ + public UserAliases(final UserAliases source) + { + super(source); + } + /** * Gets the real name. * @@ -143,7 +154,7 @@ public class UserAliases extends HashMap String result; StringList buffer = new StringList(); - for (String nick : this.keySet()) + for (String nick : new StringList(this.keySet()).sort()) { buffer.appendln(getRealName(nick)); } diff --git a/src/org/april/hebdobot/review/MessageList.java b/src/org/april/hebdobot/review/MessageList.java new file mode 100644 index 0000000..43a9fd3 --- /dev/null +++ b/src/org/april/hebdobot/review/MessageList.java @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2017 Christian Pierre MOMON + * + * This file is part of (April) Hebdobot. + * + * Hebdobot is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Hebdobot is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Hebdobot. If not, see + */ +package org.april.hebdobot.review; + +import java.util.ArrayList; + +/** + * The Class MessageLinkedList. + */ +public class MessageList extends ArrayList +{ + private static final long serialVersionUID = -5568763770640883452L; + + /** + * Instantiates a new messages. + */ + public MessageList() + { + super(); + } +} diff --git a/src/org/april/hebdobot/review/Review.java b/src/org/april/hebdobot/review/Review.java index 9c81661..3a80ed8 100644 --- a/src/org/april/hebdobot/review/Review.java +++ b/src/org/april/hebdobot/review/Review.java @@ -23,13 +23,14 @@ import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; import java.util.List; -import java.util.Set; import org.apache.commons.lang3.StringUtils; import org.april.hebdobot.model.UserAliases; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; +import fr.devinsy.util.strings.StringSet; + /** * The Class Review. */ @@ -37,11 +38,11 @@ public class Review { private static final int LENGTH = 80; - private final Set participants; + private final StringSet participants; private final List individualTopics; private final List collectiveTopics; private Topic currentTopic; - private final List messages; + private final MessageList messages; private final String owner; private final UserAliases aliases; @@ -53,10 +54,10 @@ public class Review */ public Review(final String owner, final UserAliases aliases) { - this.participants = new HashSet(); + this.participants = new StringSet(); this.individualTopics = new LinkedList(); this.collectiveTopics = new LinkedList(); - this.messages = new Messages(); + this.messages = new MessageList(); this.owner = owner; this.aliases = aliases;