Skip to content

Commit

Permalink
Override iterator method
Browse files Browse the repository at this point in the history
  • Loading branch information
li-ukumar committed Apr 24, 2024
1 parent 3fb7d5b commit 88e308d
Show file tree
Hide file tree
Showing 3 changed files with 42 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 @@ -65,4 +66,21 @@ public boolean remove(Object o) {
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 @@ -66,4 +67,21 @@ public boolean remove(Object o) {
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 @@ -60,4 +61,9 @@ public boolean remove(Object o) {
public void clear() {
utf8List.clear();
}

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

0 comments on commit 88e308d

Please sign in to comment.