summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-03-17 19:46:55 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-03-17 19:46:55 -0400
commit338b2b16b6934d27dc4cd536fb5527b71985de4f (patch)
tree6dc7e85370507d22150cd7cef353a033b50a71d7 /BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java
parent5832ef0286430d04484b70d49c73e081a80ec9c7 (diff)
Add more toString/hashCode/equals
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java53
1 files changed, 47 insertions, 6 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java
index fa3e61c..64c0460 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java
@@ -9,7 +9,7 @@ package bjc.utils.esodata;
* If there is no tape currently loaded into the changer, all the methods will
* either return null/false.
*
- * @param T
+ * @param <T>
* The element type of the tapes.
*/
public class TapeChanger<T> implements Tape<T> {
@@ -26,9 +26,9 @@ public class TapeChanger<T> implements Tape<T> {
/**
* Create a new tape changer with the specified tapes.
*
- * The first tape in the list will be mounted.
- *
- * @param taps
+ * @param current
+ * The tape to mount first.
+ * @param others
* The tapes to put in this tape changer.
*/
@SafeVarargs
@@ -275,8 +275,8 @@ public class TapeChanger<T> implements Tape<T> {
*
* The specified tape is loaded.
*
- * @param The
- * tape to insert and load.
+ * @param tp
+ * The tape to insert and load.
*/
public void insertTape(Tape<T> tp) {
tapes.insertAfter(tp);
@@ -320,4 +320,45 @@ public class TapeChanger<T> implements Tape<T> {
public int tapeCount() {
return tapes.size();
}
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("TapeChanger [tapes=");
+ builder.append(tapes);
+ builder.append(", currentTape=");
+ builder.append(currentTape);
+ builder.append("]");
+
+ return builder.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((currentTape == null) ? 0 : currentTape.hashCode());
+ result = prime * result + ((tapes == null) ? 0 : tapes.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj) return true;
+ if(obj == null) return false;
+ if(getClass() != obj.getClass()) return false;
+
+ TapeChanger<?> other = (TapeChanger<?>) obj;
+
+ if(currentTape == null) {
+ if(other.currentTape != null) return false;
+ } else if(!currentTape.equals(other.currentTape)) return false;
+
+ if(tapes == null) {
+ if(other.tapes != null) return false;
+ } else if(!tapes.equals(other.tapes)) return false;
+
+ return true;
+ }
}