GeezerVison is showing github.com — squid:S1319 - Declarations should use Java collection interfaces such… · coding0011/java-design-patterns@e4c34b1
File treeExpand file treeCollapse file tree Open diff view settings caching/src/main/java/com/iluwatar/caching fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable iterator/src/main/java/com/iluwatar/iterator observer/src/test/java/com/iluwatar/observer producer-consumer/src/main/java/com/iluwatar/producer/consumer servant/src/main/java/com/iluwatar/servant
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: caching/src/main/java/com/iluwatar/caching/CacheStore.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | */ | 23 | 23 | package com.iluwatar.caching; | 24 | 24 |
| 25 | | -import java.util.ArrayList; | | 25 | +import java.util.List; | 26 | 26 |
| 27 | 27 | /** | 28 | 28 | * | @@ -134,7 +134,7 @@ public static void flushCache() { | 134 | 134 | if (null == cache) { | 135 | 135 | return; | 136 | 136 | } | 137 | | - ArrayList<UserAccount> listOfUserAccounts = cache.getCacheDataInListForm(); | | 137 | + List<UserAccount> listOfUserAccounts = cache.getCacheDataInListForm(); | 138 | 138 | for (UserAccount userAccount : listOfUserAccounts) { | 139 | 139 | DbManager.upsertDb(userAccount); | 140 | 140 | } | @@ -144,7 +144,7 @@ public static void flushCache() { | 144 | 144 | * Print user accounts | 145 | 145 | */ | 146 | 146 | public static String print() { | 147 | | - ArrayList<UserAccount> listOfUserAccounts = cache.getCacheDataInListForm(); | | 147 | + List<UserAccount> listOfUserAccounts = cache.getCacheDataInListForm(); | 148 | 148 | StringBuilder sb = new StringBuilder(); | 149 | 149 | sb.append("\n--CACHE CONTENT--\n"); | 150 | 150 | for (UserAccount userAccount : listOfUserAccounts) { | |
Collapse file Copy file name to clipboardExpand all lines: caching/src/main/java/com/iluwatar/caching/DbManager.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 24 | 24 |
| 25 | 25 | import java.text.ParseException; | 26 | 26 | import java.util.HashMap; | | 27 | +import java.util.Map; | 27 | 28 |
| 28 | 29 | import org.bson.Document; | 29 | 30 |
| @@ -49,7 +50,7 @@ public final class DbManager { | 49 | 50 | private static MongoDatabase db; | 50 | 51 | private static boolean useMongoDB; | 51 | 52 |
| 52 | | - private static HashMap<String, UserAccount> virtualDB; | | 53 | + private static Map<String, UserAccount> virtualDB; | 53 | 54 |
| 54 | 55 | private DbManager() { | 55 | 56 | } | |
Collapse file Copy file name to clipboardExpand all lines: caching/src/main/java/com/iluwatar/caching/LruCache.java +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 24 | 24 |
| 25 | 25 | import java.util.ArrayList; | 26 | 26 | import java.util.HashMap; | | 27 | +import java.util.List; | | 28 | +import java.util.Map; | 27 | 29 |
| 28 | 30 | /** | 29 | 31 | * | @@ -49,7 +51,7 @@ public Node(String userId, UserAccount userAccount) { | 49 | 51 | } | 50 | 52 |
| 51 | 53 | int capacity; | 52 | | - HashMap<String, Node> cache = new HashMap<>(); | | 54 | + Map<String, Node> cache = new HashMap<>(); | 53 | 55 | Node head; | 54 | 56 | Node end; | 55 | 57 |
| @@ -161,7 +163,7 @@ public void clear() { | 161 | 163 | * | 162 | 164 | * Returns cache data in list form. | 163 | 165 | */ | 164 | | - public ArrayList<UserAccount> getCacheDataInListForm() { | | 166 | + public List<UserAccount> getCacheDataInListForm() { | 165 | 167 | ArrayList<UserAccount> listOfCacheData = new ArrayList<>(); | 166 | 168 | Node temp = head; | 167 | 169 | while (temp != null) { | |
Collapse file Copy file name to clipboardExpand all lines: fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterable.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -101,7 +101,7 @@ public interface FluentIterable<E> extends Iterable<E> { | 101 | 101 | * @return a list with all objects of the given iterator | 102 | 102 | */ | 103 | 103 | static <E> List<E> copyToList(Iterable<E> iterable) { | 104 | | - ArrayList<E> copy = new ArrayList<>(); | | 104 | + List<E> copy = new ArrayList<>(); | 105 | 105 | Iterator<E> iterator = iterable.iterator(); | 106 | 106 | while (iterator.hasNext()) { | 107 | 107 | copy.add(iterator.next()); | |
Collapse file Copy file name to clipboardExpand all lines: iterator/src/main/java/com/iluwatar/iterator/TreasureChest.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -59,7 +59,7 @@ ItemIterator iterator(ItemType itemType) { | 59 | 59 | * Get all items | 60 | 60 | */ | 61 | 61 | public List<Item> getItems() { | 62 | | - ArrayList<Item> list = new ArrayList<>(); | | 62 | + List<Item> list = new ArrayList<>(); | 63 | 63 | list.addAll(items); | 64 | 64 | return list; | 65 | 65 | } | |
Collapse file Copy file name to clipboardExpand all lines: observer/src/test/java/com/iluwatar/observer/HobbitsTest.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 27 | 27 |
| 28 | 28 | import java.util.ArrayList; | 29 | 29 | import java.util.Collection; | | 30 | +import java.util.List; | 30 | 31 |
| 31 | 32 | /** | 32 | 33 | * Date: 12/27/15 - 12:07 PM | @@ -38,7 +39,7 @@ public class HobbitsTest extends WeatherObserverTest<Hobbits> { | 38 | 39 |
| 39 | 40 | @Parameterized.Parameters | 40 | 41 | public static Collection<Object[]> data() { | 41 | | - final ArrayList<Object[]> testData = new ArrayList<>(); | | 42 | + final List<Object[]> testData = new ArrayList<>(); | 42 | 43 | testData.add(new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."}); | 43 | 44 | testData.add(new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."}); | 44 | 45 | testData.add(new Object[]{WeatherType.WINDY, "The hobbits hold their hats tightly in the windy weather."}); | |
Collapse file Copy file name to clipboardExpand all lines: observer/src/test/java/com/iluwatar/observer/OrcsTest.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 27 | 27 |
| 28 | 28 | import java.util.ArrayList; | 29 | 29 | import java.util.Collection; | | 30 | +import java.util.List; | 30 | 31 |
| 31 | 32 | /** | 32 | 33 | * Date: 12/27/15 - 12:07 PM | @@ -38,7 +39,7 @@ public class OrcsTest extends WeatherObserverTest<Orcs> { | 38 | 39 |
| 39 | 40 | @Parameterized.Parameters | 40 | 41 | public static Collection<Object[]> data() { | 41 | | - final ArrayList<Object[]> testData = new ArrayList<>(); | | 42 | + final List<Object[]> testData = new ArrayList<>(); | 42 | 43 | testData.add(new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."}); | 43 | 44 | testData.add(new Object[]{WeatherType.RAINY, "The orcs are dripping wet."}); | 44 | 45 | testData.add(new Object[]{WeatherType.WINDY, "The orc smell almost vanishes in the wind."}); | |
Collapse file Copy file name to clipboardExpand all lines: observer/src/test/java/com/iluwatar/observer/generic/GHobbitsTest.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 31 | 31 |
| 32 | 32 | import java.util.ArrayList; | 33 | 33 | import java.util.Collection; | | 34 | +import java.util.List; | 34 | 35 |
| 35 | 36 | /** | 36 | 37 | * Date: 12/27/15 - 12:07 PM | @@ -42,7 +43,7 @@ public class GHobbitsTest extends ObserverTest<GHobbits> { | 42 | 43 |
| 43 | 44 | @Parameterized.Parameters | 44 | 45 | public static Collection<Object[]> data() { | 45 | | - final ArrayList<Object[]> testData = new ArrayList<>(); | | 46 | + final List<Object[]> testData = new ArrayList<>(); | 46 | 47 | testData.add(new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."}); | 47 | 48 | testData.add(new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."}); | 48 | 49 | testData.add(new Object[]{WeatherType.WINDY, "The hobbits hold their hats tightly in the windy weather."}); | |
Collapse file Copy file name to clipboardExpand all lines: observer/src/test/java/com/iluwatar/observer/generic/OrcsTest.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 29 | 29 |
| 30 | 30 | import java.util.ArrayList; | 31 | 31 | import java.util.Collection; | | 32 | +import java.util.List; | 32 | 33 |
| 33 | 34 | /** | 34 | 35 | * Date: 12/27/15 - 12:07 PM | @@ -40,7 +41,7 @@ public class OrcsTest extends ObserverTest<GOrcs> { | 40 | 41 |
| 41 | 42 | @Parameterized.Parameters | 42 | 43 | public static Collection<Object[]> data() { | 43 | | - final ArrayList<Object[]> testData = new ArrayList<>(); | | 44 | + final List<Object[]> testData = new ArrayList<>(); | 44 | 45 | testData.add(new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."}); | 45 | 46 | testData.add(new Object[]{WeatherType.RAINY, "The orcs are dripping wet."}); | 46 | 47 | testData.add(new Object[]{WeatherType.WINDY, "The orc smell almost vanishes in the wind."}); | |
Collapse file Copy file name to clipboardExpand all lines: producer-consumer/src/main/java/com/iluwatar/producer/consumer/ItemQueue.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | */ | 23 | 23 | package com.iluwatar.producer.consumer; | 24 | 24 |
| | 25 | +import java.util.concurrent.BlockingQueue; | 25 | 26 | import java.util.concurrent.LinkedBlockingQueue; | 26 | 27 |
| 27 | 28 | /** | 28 | 29 | * Class as a channel for {@link Producer}-{@link Consumer} exchange. | 29 | 30 | */ | 30 | 31 | public class ItemQueue { | 31 | 32 |
| 32 | | - private LinkedBlockingQueue<Item> queue; | | 33 | + private BlockingQueue<Item> queue; | 33 | 34 |
| 34 | 35 | public ItemQueue() { | 35 | 36 |
| |
|