Skip to content

Commit 14eedc1

Browse files
committed
Fixed UnOrdered elements in contents of Log.
Resolved Issue #6 by switching data-type of HashMap to one of it's derivatives, LinkedHashMap. Also performed some minor clean-up of methods and variables in logUtils. (Took care of/Suppressed some compiler warnings)
1 parent 3f22c37 commit 14eedc1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/logUtils/Log.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package logUtils;
22

33
import java.util.ArrayList;
4-
import java.util.HashMap;
4+
import java.util.LinkedHashMap;
55
import java.util.Map;
66

77
/**
@@ -18,14 +18,14 @@ public class Log {
1818
/**
1919
* The raw contents of the log.
2020
*/
21-
private HashMap<String, ArrayList<Object>> contents;
21+
private LinkedHashMap<String, ArrayList<Object>> contents;
2222

2323

2424
/**
2525
* Default Constructor.
2626
*/
2727
public Log(){
28-
contents = new HashMap<>();
28+
contents = new LinkedHashMap<>();
2929
}
3030

3131
/**
@@ -47,7 +47,7 @@ public Log(Log copyFrom){
4747
* @param key The "key" of the data to log.
4848
* @param object The actual data to write to that key.
4949
*/
50-
public void append(String key, Object object){
50+
void append(String key, Object object){
5151
if (!contents.containsKey(key))
5252
contents.put(key, new ArrayList<>());
5353
contents.get(key).add(object);
@@ -60,8 +60,9 @@ public void append(String key, Object object){
6060
*
6161
* @return A copy of the contents of the log in it's raw hashmap form.
6262
*/
63-
private HashMap<String, ArrayList<Object>> getRaw(){
64-
return (HashMap<String, ArrayList<Object>>) contents.clone();
63+
@SuppressWarnings("unchecked")
64+
private LinkedHashMap<String, ArrayList<Object>> getRaw(){
65+
return (LinkedHashMap<String, ArrayList<Object>>) contents.clone();
6566
}
6667

6768

src/logUtils/Loggable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
*/
1212
public abstract class Loggable {
1313

14-
String[] keys;
14+
private String[] keys;
1515

1616
/**
1717
* The {@link Log} object that stores all logged values for this class.
1818
*/
19-
Log log;
19+
private Log log;
2020

2121
/**
2222
* Constructor

0 commit comments

Comments
 (0)