squid:S1319 - Declarations should use Java collection interfaces such as List rather than specific implementation classes such as LinkedList

This commit is contained in:
Mohammed Ezzat 2016-02-22 19:39:26 +02:00
parent c580b61df3
commit e4c34b1e22
11 changed files with 23 additions and 15 deletions

View File

@ -22,7 +22,7 @@
*/
package com.iluwatar.caching;
import java.util.ArrayList;
import java.util.List;
/**
*
@ -134,7 +134,7 @@ public class CacheStore {
if (null == cache) {
return;
}
ArrayList<UserAccount> listOfUserAccounts = cache.getCacheDataInListForm();
List<UserAccount> listOfUserAccounts = cache.getCacheDataInListForm();
for (UserAccount userAccount : listOfUserAccounts) {
DbManager.upsertDb(userAccount);
}
@ -144,7 +144,7 @@ public class CacheStore {
* Print user accounts
*/
public static String print() {
ArrayList<UserAccount> listOfUserAccounts = cache.getCacheDataInListForm();
List<UserAccount> listOfUserAccounts = cache.getCacheDataInListForm();
StringBuilder sb = new StringBuilder();
sb.append("\n--CACHE CONTENT--\n");
for (UserAccount userAccount : listOfUserAccounts) {

View File

@ -24,6 +24,7 @@ package com.iluwatar.caching;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import org.bson.Document;
@ -49,7 +50,7 @@ public final class DbManager {
private static MongoDatabase db;
private static boolean useMongoDB;
private static HashMap<String, UserAccount> virtualDB;
private static Map<String, UserAccount> virtualDB;
private DbManager() {
}

View File

@ -24,6 +24,8 @@ package com.iluwatar.caching;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
@ -49,7 +51,7 @@ public class LruCache {
}
int capacity;
HashMap<String, Node> cache = new HashMap<>();
Map<String, Node> cache = new HashMap<>();
Node head;
Node end;
@ -161,7 +163,7 @@ public class LruCache {
*
* Returns cache data in list form.
*/
public ArrayList<UserAccount> getCacheDataInListForm() {
public List<UserAccount> getCacheDataInListForm() {
ArrayList<UserAccount> listOfCacheData = new ArrayList<>();
Node temp = head;
while (temp != null) {

View File

@ -101,7 +101,7 @@ public interface FluentIterable<E> extends Iterable<E> {
* @return a list with all objects of the given iterator
*/
static <E> List<E> copyToList(Iterable<E> iterable) {
ArrayList<E> copy = new ArrayList<>();
List<E> copy = new ArrayList<>();
Iterator<E> iterator = iterable.iterator();
while (iterator.hasNext()) {
copy.add(iterator.next());

View File

@ -59,7 +59,7 @@ public class TreasureChest {
* Get all items
*/
public List<Item> getItems() {
ArrayList<Item> list = new ArrayList<>();
List<Item> list = new ArrayList<>();
list.addAll(items);
return list;
}

View File

@ -27,6 +27,7 @@ import org.junit.runners.Parameterized;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Date: 12/27/15 - 12:07 PM
@ -38,7 +39,7 @@ public class HobbitsTest extends WeatherObserverTest<Hobbits> {
@Parameterized.Parameters
public static Collection<Object[]> data() {
final ArrayList<Object[]> testData = new ArrayList<>();
final List<Object[]> testData = new ArrayList<>();
testData.add(new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."});
testData.add(new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."});
testData.add(new Object[]{WeatherType.WINDY, "The hobbits hold their hats tightly in the windy weather."});

View File

@ -27,6 +27,7 @@ import org.junit.runners.Parameterized;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Date: 12/27/15 - 12:07 PM
@ -38,7 +39,7 @@ public class OrcsTest extends WeatherObserverTest<Orcs> {
@Parameterized.Parameters
public static Collection<Object[]> data() {
final ArrayList<Object[]> testData = new ArrayList<>();
final List<Object[]> testData = new ArrayList<>();
testData.add(new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."});
testData.add(new Object[]{WeatherType.RAINY, "The orcs are dripping wet."});
testData.add(new Object[]{WeatherType.WINDY, "The orc smell almost vanishes in the wind."});

View File

@ -31,6 +31,7 @@ import org.junit.runners.Parameterized;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Date: 12/27/15 - 12:07 PM
@ -42,7 +43,7 @@ public class GHobbitsTest extends ObserverTest<GHobbits> {
@Parameterized.Parameters
public static Collection<Object[]> data() {
final ArrayList<Object[]> testData = new ArrayList<>();
final List<Object[]> testData = new ArrayList<>();
testData.add(new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."});
testData.add(new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."});
testData.add(new Object[]{WeatherType.WINDY, "The hobbits hold their hats tightly in the windy weather."});

View File

@ -29,6 +29,7 @@ import org.junit.runners.Parameterized;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Date: 12/27/15 - 12:07 PM
@ -40,7 +41,7 @@ public class OrcsTest extends ObserverTest<GOrcs> {
@Parameterized.Parameters
public static Collection<Object[]> data() {
final ArrayList<Object[]> testData = new ArrayList<>();
final List<Object[]> testData = new ArrayList<>();
testData.add(new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."});
testData.add(new Object[]{WeatherType.RAINY, "The orcs are dripping wet."});
testData.add(new Object[]{WeatherType.WINDY, "The orc smell almost vanishes in the wind."});

View File

@ -22,6 +22,7 @@
*/
package com.iluwatar.producer.consumer;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
/**
@ -29,7 +30,7 @@ import java.util.concurrent.LinkedBlockingQueue;
*/
public class ItemQueue {
private LinkedBlockingQueue<Item> queue;
private BlockingQueue<Item> queue;
public ItemQueue() {

View File

@ -22,7 +22,7 @@
*/
package com.iluwatar.servant;
import java.util.ArrayList;
import java.util.List;
/**
*
@ -55,7 +55,7 @@ public class Servant {
/**
* Check if we will be hanged
*/
public boolean checkIfYouWillBeHanged(ArrayList<Royalty> tableGuests) {
public boolean checkIfYouWillBeHanged(List<Royalty> tableGuests) {
boolean anotherDay = true;
for (Royalty r : tableGuests) {
if (!r.getMood()) {