summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/ObservableArray.java
diff options
context:
space:
mode:
Diffstat (limited to 'projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/ObservableArray.java')
-rw-r--r--projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/ObservableArray.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/ObservableArray.java b/projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/ObservableArray.java
index e18ed3b..7755e8f 100644
--- a/projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/ObservableArray.java
+++ b/projects/net.wotonomy.ui/src/main/java/net/wotonomy/ui/ObservableArray.java
@@ -36,7 +36,9 @@ import net.wotonomy.foundation.NSRange;
* probably call each other. However, EOObserverCenter will only register us
* once per object.
*/
-class ObservableArray extends NSMutableArray {
+class ObservableArray<T> extends NSMutableArray<T> {
+ private static final long serialVersionUID = 9098414040194393263L;
+
EOObserving observer;
ObservableArray(EOObserving anObserver) {
@@ -60,7 +62,7 @@ class ObservableArray extends NSMutableArray {
/**
* Adds all objects in the specified collection.
*/
- public void addObjectsFromArray(Collection aCollection) {
+ public void addObjectsFromArray(Collection<T> aCollection) {
addAll(aCollection);
}
@@ -112,7 +114,7 @@ class ObservableArray extends NSMutableArray {
/**
* Removes all objects in the specified collection from the array.
*/
- public void removeObjectsInArray(Collection aCollection) {
+ public void removeObjectsInArray(Collection<T> aCollection) {
removeAll(aCollection);
}
@@ -134,7 +136,7 @@ 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) {
+ public void replaceObjectsInRange(NSRange currentRange, List<T> otherArray, NSRange otherRange) {
if ((currentRange == null) || (otherArray == null) || (otherRange == null))
return;
@@ -183,7 +185,7 @@ class ObservableArray extends NSMutableArray {
/**
* Removes all occurences of the specified object, comparing by reference.
*/
- public void removeIdenticalObject(Object anObject) {
+ public void removeIdenticalObject(T anObject) {
EOObserverCenter.removeObserver(observer, anObject);
super.removeIdenticalObject(anObject);
}
@@ -191,32 +193,32 @@ class ObservableArray extends NSMutableArray {
/**
* Inserts the specified object into this array at the specified index.
*/
- public void insertObjectAtIndex(Object anObject, int anIndex) {
+ 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) {
+ 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) {
+ public void addObject(T anObject) {
add(anObject);
}
// interface List: mutators
- public void add(int index, Object element) {
+ public void add(int index, T element) {
EOObserverCenter.addObserver(observer, element);
super.add(index, element);
}
- public boolean add(Object o) {
+ public boolean add(T o) {
EOObserverCenter.addObserver(observer, o);
return super.add(o);
}
@@ -245,7 +247,7 @@ class ObservableArray extends NSMutableArray {
super.clear();
}
- public Object remove(int index) {
+ public T remove(int index) {
EOObserverCenter.removeObserver(observer, get(index));
return super.remove(index);
}
@@ -267,7 +269,7 @@ class ObservableArray extends NSMutableArray {
throw new UnsupportedOperationException();
}
- public Object set(int index, Object element) {
+ public T set(int index, T element) {
EOObserverCenter.removeObserver(observer, get(index));
EOObserverCenter.addObserver(observer, element);
return super.set(index, element);