Using List instead of ArrayList (PMD)
This commit is contained in:
parent
c3d4eb1ab8
commit
bb23d7e79d
5 changed files with 15 additions and 10 deletions
|
@ -46,6 +46,7 @@ import org.json.JSONObject;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The StockQuote module.
|
||||
|
@ -80,7 +81,7 @@ public final class StockQuote extends ThreadedModule {
|
|||
* @return The {@link Message} array containing the stock quote.
|
||||
* @throws ModuleException If an errors occurs.
|
||||
*/
|
||||
static ArrayList<Message> getQuote(final String symbol, final String apiKey) throws ModuleException {
|
||||
static List<Message> getQuote(final String symbol, final String apiKey) throws ModuleException {
|
||||
if (!Utils.isValidString(apiKey)) {
|
||||
throw new ModuleException(Utils.capitalize(STOCK_CMD) + " is disabled. The API key is missing.");
|
||||
}
|
||||
|
@ -166,10 +167,11 @@ public final class StockQuote extends ThreadedModule {
|
|||
/**
|
||||
* Returns the specified stock quote from Alpha Advantage.
|
||||
*/
|
||||
@Override
|
||||
void run(final Mobibot bot, final String sender, final String symbol) {
|
||||
if (Utils.isValidString(symbol)) {
|
||||
try {
|
||||
final ArrayList<Message> messages = getQuote(symbol, properties.get(ALPHAVANTAGE_API_KEY_PROP));
|
||||
final List<Message> messages = getQuote(symbol, properties.get(ALPHAVANTAGE_API_KEY_PROP));
|
||||
for (final Message msg : messages) {
|
||||
bot.send(sender, msg);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public class Weather2 extends ThreadedModule {
|
|||
* @return The {@link Message} array containing the weather data.
|
||||
* @throws ModuleException If an error occurs while retrieving the weather data.
|
||||
*/
|
||||
static ArrayList<Message> getWeather(final String query, final String apiKey) throws ModuleException {
|
||||
static List<Message> getWeather(final String query, final String apiKey) throws ModuleException {
|
||||
if (!Utils.isValidString(apiKey)) {
|
||||
throw new ModuleException(Utils.capitalize(WEATHER_CMD) + " is disabled. The API key is missing.");
|
||||
}
|
||||
|
@ -204,10 +204,11 @@ public class Weather2 extends ThreadedModule {
|
|||
/**
|
||||
* Fetches the weather data from a specific city.
|
||||
*/
|
||||
@Override
|
||||
void run(final Mobibot bot, final String sender, final String args) {
|
||||
if (Utils.isValidString(args)) {
|
||||
try {
|
||||
final ArrayList<Message> messages = getWeather(args, properties.get(OWM_API_KEY_PROP));
|
||||
final List<Message> messages = getWeather(args, properties.get(OWM_API_KEY_PROP));
|
||||
if (messages.get(0).isError()) {
|
||||
helpResponse(bot, sender, args, true);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue