From 889fac2bdf993dc86f64a8893c0260fdcf848acb Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 10 Apr 2017 16:40:33 -0400 Subject: Cleanup --- .../main/java/bjc/utils/esodata/TapeChanger.java | 90 +++++++++------------- 1 file changed, 35 insertions(+), 55 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java') 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 10764fe..8b8613f 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java @@ -32,12 +32,12 @@ public class TapeChanger implements Tape { * The tapes to put in this tape changer. */ @SafeVarargs - public TapeChanger(Tape current, Tape... others) { + public TapeChanger(final Tape current, final Tape... others) { this(); tapes.insertBefore(current); - for (Tape tp : others) { + for (final Tape tp : others) { tapes.insertAfter(tp); tapes.right(); } @@ -53,8 +53,7 @@ public class TapeChanger implements Tape { */ @Override public T item() { - if (currentTape == null) - return null; + if (currentTape == null) return null; return currentTape.item(); } @@ -66,9 +65,8 @@ public class TapeChanger implements Tape { * The new value for the tape item. */ @Override - public void item(T itm) { - if (currentTape == null) - return; + public void item(final T itm) { + if (currentTape == null) return; currentTape.item(itm); } @@ -80,8 +78,7 @@ public class TapeChanger implements Tape { */ @Override public int size() { - if (currentTape == null) - return 0; + if (currentTape == null) return 0; return currentTape.size(); } @@ -93,9 +90,8 @@ public class TapeChanger implements Tape { * The item to add. */ @Override - public void insertBefore(T itm) { - if (currentTape == null) - return; + public void insertBefore(final T itm) { + if (currentTape == null) return; currentTape.insertBefore(itm); } @@ -104,9 +100,8 @@ public class TapeChanger implements Tape { * Insert an element after the current item. */ @Override - public void insertAfter(T itm) { - if (currentTape == null) - return; + public void insertAfter(final T itm) { + if (currentTape == null) return; currentTape.insertAfter(itm); } @@ -121,8 +116,7 @@ public class TapeChanger implements Tape { */ @Override public T remove() { - if (currentTape == null) - return null; + if (currentTape == null) return null; return currentTape.remove(); } @@ -132,8 +126,7 @@ public class TapeChanger implements Tape { */ @Override public void first() { - if (currentTape == null) - return; + if (currentTape == null) return; currentTape.first(); } @@ -143,8 +136,7 @@ public class TapeChanger implements Tape { */ @Override public void last() { - if (currentTape == null) - return; + if (currentTape == null) return; currentTape.last(); } @@ -173,9 +165,8 @@ public class TapeChanger implements Tape { * @return True if the cursor was moved left. */ @Override - public boolean left(int amt) { - if (currentTape == null) - return false; + public boolean left(final int amt) { + if (currentTape == null) return false; return currentTape.left(amt); } @@ -203,9 +194,8 @@ public class TapeChanger implements Tape { * @return Whether the cursor was moved right. */ @Override - public boolean right(int amt) { - if (currentTape == null) - return false; + public boolean right(final int amt) { + if (currentTape == null) return false; return currentTape.right(amt); } @@ -219,8 +209,7 @@ public class TapeChanger implements Tape { * If the current tape is not double-sided, does nothing. */ public void flip() { - if (currentTape == null) - return; + if (currentTape == null) return; if (currentTape.isDoubleSided()) { ((DoubleTape) currentTape).flip(); @@ -229,8 +218,7 @@ public class TapeChanger implements Tape { @Override public boolean isDoubleSided() { - if (currentTape == null) - return false; + if (currentTape == null) return false; return currentTape.isDoubleSided(); } @@ -253,7 +241,7 @@ public class TapeChanger implements Tape { * @return Whether or not the next tape was loaded. */ public boolean nextTape() { - boolean succ = tapes.right(); + final boolean succ = tapes.right(); if (succ) { currentTape = tapes.item(); @@ -271,7 +259,7 @@ public class TapeChanger implements Tape { * @return Whether or not the previous tape was loaded. */ public boolean prevTape() { - boolean succ = tapes.left(); + final boolean succ = tapes.left(); if (succ) { currentTape = tapes.item(); @@ -290,7 +278,7 @@ public class TapeChanger implements Tape { * @param tp * The tape to insert and load. */ - public void insertTape(Tape tp) { + public void insertTape(final Tape tp) { tapes.insertAfter(tp); tapes.right(); @@ -307,10 +295,9 @@ public class TapeChanger implements Tape { * @return The removed tape. */ public Tape removeTape() { - if (currentTape == null) - return null; + if (currentTape == null) return null; - Tape tp = tapes.remove(); + final Tape tp = tapes.remove(); currentTape = tapes.item(); return tp; @@ -338,33 +325,26 @@ public class TapeChanger implements Tape { 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()); + 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 (!(obj instanceof TapeChanger)) - return false; + public boolean equals(final Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (!(obj instanceof TapeChanger)) return false; - TapeChanger other = (TapeChanger) obj; + final TapeChanger other = (TapeChanger) obj; if (currentTape == null) { - if (other.currentTape != null) - return false; - } else if (!currentTape.equals(other.currentTape)) - return false; + 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; + if (other.tapes != null) return false; + } else if (!tapes.equals(other.tapes)) return false; return true; } -- cgit v1.2.3