hebdobot/src/org/april/hebdobot/review/IndividualTopic.java

93 lines
2.4 KiB
Java

/**
* Copyright (C) 2011-2013 Nicolas Vinot <aeris@imirhil.fr>
* Copyright (C) 2017 Christian Pierre MOMON <cmomon@april.org>
*
* 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 <http://www.gnu.org/licenses/>
*/
package org.april.hebdobot.review;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* The Class IndividualTopic.
*/
public class IndividualTopic extends Topic
{
private final Map<String, Messages> messages;
/**
* Instantiates a new individual topic.
*
* @param title
* the title
*/
public IndividualTopic(final String title)
{
super(title);
this.messages = new HashMap<String, Messages>();
}
/* (non-Javadoc)
* @see org.april.hebdobot.review.Topic#add(org.april.hebdobot.review.Message)
*/
@Override
public void add(final Message message)
{
final String author = message.getAuthor();
if (!this.messages.containsKey(author))
{
this.messages.put(author, new Messages());
}
this.messages.get(author).add(message);
}
/**
* Gets the messages.
*
* @param author
* the author
* @return the messages
*/
public Messages getMessages(final String author)
{
return this.messages.get(author);
}
/* (non-Javadoc)
* @see org.april.hebdobot.review.Topic#getParticipants()
*/
@Override
public Set<String> getParticipants()
{
return this.messages.keySet();
}
/**
* Checks for participant.
*
* @param participant
* the participant
* @return true, if successful
*/
public boolean hasParticipant(final String participant)
{
return this.messages.containsKey(participant);
}
}