From 02bc52037e9ccccca672d6156d9c325c74fe28b3 Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 1 Jul 2024 17:27:48 -0400 Subject: Update a whole bunch of things Yeah... not a great commit message. t.b.h, I could maybe've split the commit into more parts; but that would be quite a lot off effort and would have a pretty decent chance of at least one of the commits leaving the repository in a non-working state. For the future, will want to try and commit more often so there aren't these mega-commits where it's just "a whole bunch of stuff changed" --- .../java/net/wotonomy/web/ObservableArray.java | 75 ++++++++++++++-------- 1 file changed, 50 insertions(+), 25 deletions(-) (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/ObservableArray.java') diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/ObservableArray.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/ObservableArray.java index 1c91115..90d234d 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/ObservableArray.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/ObservableArray.java @@ -36,7 +36,8 @@ import net.wotonomy.foundation.NSRange; * probably call each other. However, EOObserverCenter will only register us * once per object. */ -class ObservableArray extends NSMutableArray { +class ObservableArray extends NSMutableArray { + private static final long serialVersionUID = 1166339693880765234L; EOObserving observer; ObservableArray(EOObserving anObserver) { @@ -46,6 +47,7 @@ class ObservableArray extends NSMutableArray { /** * Removes the last object from the array. */ + @Override public void removeLastObject() { remove(count() - 1); } @@ -53,6 +55,7 @@ class ObservableArray extends NSMutableArray { /** * Removes the object at the specified index. */ + @Override public void removeObjectAtIndex(int index) { remove(index); } @@ -60,13 +63,15 @@ class ObservableArray extends NSMutableArray { /** * Adds all objects in the specified collection. */ - public void addObjectsFromArray(Collection aCollection) { + @Override + public void addObjectsFromArray(Collection aCollection) { addAll(aCollection); } /** * Removes all objects from the array. */ + @Override public void removeAllObjects() { clear(); } @@ -75,7 +80,8 @@ class ObservableArray extends NSMutableArray { * Removes all objects equivalent to the specified object within the range of * specified indices. */ - public void removeObject(Object anObject, NSRange aRange) { + @Override + public void removeObject(T anObject, NSRange aRange) { if ((anObject == null) || (aRange == null)) return; @@ -94,7 +100,8 @@ class ObservableArray extends NSMutableArray { * Removes all instances of the specified object within the range of specified * indices, comparing by reference. */ - public void removeIdenticalObject(Object anObject, NSRange aRange) { + @Override + public void removeIdenticalObject(T anObject, NSRange aRange) { if ((anObject == null) || (aRange == null)) return; @@ -112,13 +119,15 @@ class ObservableArray extends NSMutableArray { /** * Removes all objects in the specified collection from the array. */ - public void removeObjectsInArray(Collection aCollection) { + @Override + public void removeObjectsInArray(Collection aCollection) { removeAll(aCollection); } /** * Removes all objects in the indices within the specified range from the array. */ + @Override public void removeObjectsInRange(NSRange aRange) { if (aRange == null) return; @@ -134,7 +143,8 @@ class ObservableArray extends NSMutableArray { * objects are removed. If otherRange is larger than currentRange, the extra * objects are added. */ - public void replaceObjectsInRange(NSRange currentRange, List otherArray, NSRange otherRange) { + @Override + public void replaceObjectsInRange(NSRange currentRange, List otherArray, NSRange otherRange) { if ((currentRange == null) || (otherArray == null) || (otherRange == null)) return; @@ -145,8 +155,7 @@ class ObservableArray extends NSMutableArray { otherRange = new NSRange(loc, otherArray.size() - loc); } - Object o; - List subList = subList(currentRange.location(), currentRange.maxRange()); + List subList = subList(currentRange.location(), currentRange.maxRange()); int otherIndex = otherRange.location(); // TODO: Test this logic. for (int i = 0; i < subList.size(); i++) { @@ -168,7 +177,8 @@ class ObservableArray extends NSMutableArray { * Clears the current array and then populates it with the contents of the * specified collection. */ - public void setArray(Collection aCollection) { + @Override + public void setArray(Collection aCollection) { clear(); addAll(aCollection); } @@ -176,6 +186,7 @@ class ObservableArray extends NSMutableArray { /** * Removes all objects equivalent to the specified object. */ + @Override public void removeObject(Object anObject) { remove(anObject); } @@ -183,7 +194,8 @@ class ObservableArray extends NSMutableArray { /** * Removes all occurences of the specified object, comparing by reference. */ - public void removeIdenticalObject(Object anObject) { + @Override + public void removeIdenticalObject(T anObject) { EOObserverCenter.removeObserver(observer, anObject); super.removeIdenticalObject(anObject); } @@ -191,83 +203,96 @@ class ObservableArray extends NSMutableArray { /** * Inserts the specified object into this array at the specified index. */ - public void insertObjectAtIndex(Object anObject, int anIndex) { + @Override + public void insertObjectAtIndex(T anObject, int anIndex) { add(anIndex, anObject); } /** * Replaces the object at the specified index with the specified object. */ - public void replaceObjectAtIndex(int anIndex, Object anObject) { + @Override + public void replaceObjectAtIndex(int anIndex, T anObject) { set(anIndex, anObject); } /** * Adds the specified object to the end of this array. */ - public void addObject(Object anObject) { + @Override + public void addObject(T anObject) { add(anObject); } // interface List: mutators - public void add(int index, Object element) { + @Override + public void add(int index, T element) { EOObserverCenter.addObserver(observer, element); super.add(index, element); } - public boolean add(Object o) { + @Override + public boolean add(T o) { EOObserverCenter.addObserver(observer, o); return super.add(o); } - public boolean addAll(Collection coll) { - Iterator it = coll.iterator(); + @Override + public boolean addAll(Collection coll) { + Iterator it = coll.iterator(); while (it.hasNext()) { EOObserverCenter.addObserver(observer, it.next()); } return super.addAll(coll); } - public boolean addAll(int index, Collection c) { - Iterator it = c.iterator(); + @Override + public boolean addAll(int index, Collection c) { + Iterator it = c.iterator(); while (it.hasNext()) { EOObserverCenter.addObserver(observer, it.next()); } return super.addAll(index, c); } + @Override public void clear() { - Iterator it = iterator(); + Iterator it = iterator(); while (it.hasNext()) { EOObserverCenter.removeObserver(observer, it.next()); } super.clear(); } - public Object remove(int index) { + @Override + public T remove(int index) { EOObserverCenter.removeObserver(observer, get(index)); return super.remove(index); } + @Override public boolean remove(Object o) { EOObserverCenter.removeObserver(observer, o); return super.remove(o); } - public boolean removeAll(Collection coll) { - Iterator it = coll.iterator(); + @Override + public boolean removeAll(Collection coll) { + Iterator it = coll.iterator(); while (it.hasNext()) { EOObserverCenter.removeObserver(observer, it.next()); } return super.removeAll(coll); } - public boolean retainAll(Collection coll) { + @Override + public boolean retainAll(Collection coll) { throw new UnsupportedOperationException(); } - public Object set(int index, Object element) { + @Override + public T set(int index, T element) { EOObserverCenter.removeObserver(observer, get(index)); EOObserverCenter.addObserver(observer, element); return super.set(index, element); -- cgit v1.2.3