From 83700823d0a592c25b3efee16797774c8df75bd5 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 28 Sep 2022 09:53:01 +0200 Subject: [PATCH] Simplify `remove` method --- app/src/main/java/ch/nuth/zhaw/exbox/MyList.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/src/main/java/ch/nuth/zhaw/exbox/MyList.java b/app/src/main/java/ch/nuth/zhaw/exbox/MyList.java index d66076d..718011a 100644 --- a/app/src/main/java/ch/nuth/zhaw/exbox/MyList.java +++ b/app/src/main/java/ch/nuth/zhaw/exbox/MyList.java @@ -197,18 +197,9 @@ public class MyList extends AbstractList { } @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) public boolean remove(Object o) { for (IListNode node = getAnchor().getNextNode(); node != getAnchor(); node = node.getNextNode()) { - boolean isEqual = false; - - try { - isEqual = ((Comparable) o).compareTo((node.getItem())) == 0; - } catch (Exception e) { - isEqual = node.getItem() == o; - } - - if (isEqual) { + if (node.getItem().equals(o)) { node.getPreviousNode().setNextNode(node.getNextNode()); node.getNextNode().setPreviousNode(node.getPreviousNode()); return true;