Skip to content

Commit

Permalink
Override clear method in custom list views (#555)
Browse files Browse the repository at this point in the history
* Override clear method in custom list views

* Override iterator method
  • Loading branch information
li-ukumar authored Apr 24, 2024
1 parent 46c92a9 commit 9321e76
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.linkedin.avroutil1.compatibility.collectiontransformer;

import java.util.AbstractList;
import java.util.Iterator;
import org.apache.avro.util.Utf8;


Expand Down Expand Up @@ -60,4 +61,26 @@ public boolean addAll(int index, java.util.Collection<? extends CharSequence> c)
public boolean remove(Object o) {
return utf8List.remove(new Utf8(o.toString()));
}

@Override
public void clear() {
utf8List.clear();
}

@Override
public Iterator<CharSequence> iterator() {
return new Iterator<CharSequence>() {
private final Iterator<Utf8> iter = utf8List.iterator();

@Override
public boolean hasNext() {
return iter.hasNext();
}

@Override
public CharSequence next() {
return String.valueOf(iter.next());
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.linkedin.avroutil1.compatibility.collectiontransformer;

import java.util.AbstractList;
import java.util.Iterator;
import org.apache.avro.util.Utf8;


Expand Down Expand Up @@ -61,4 +62,26 @@ public boolean addAll(int index, java.util.Collection<? extends String> c) {
public boolean remove(Object o) {
return _utf8List.remove(new Utf8(o.toString()));
}

@Override
public void clear() {
_utf8List.clear();
}

@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
private final Iterator<Utf8> _iter = _utf8List.iterator();

@Override
public boolean hasNext() {
return _iter.hasNext();
}

@Override
public String next() {
return String.valueOf(_iter.next());
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.linkedin.avroutil1.compatibility.collectiontransformer;

import java.util.AbstractList;
import java.util.Iterator;
import org.apache.avro.util.Utf8;


Expand Down Expand Up @@ -55,4 +56,14 @@ public boolean addAll(int index, java.util.Collection<? extends Utf8> c) {
public boolean remove(Object o) {
return utf8List.remove(o);
}

@Override
public void clear() {
utf8List.clear();
}

@Override
public Iterator<Utf8> iterator() {
return utf8List.iterator();
}
}

0 comments on commit 9321e76

Please sign in to comment.