diff --git a/helper/helper/src/main/java/com/linkedin/avroutil1/compatibility/collectiontransformer/StringListView.java b/helper/helper/src/main/java/com/linkedin/avroutil1/compatibility/collectiontransformer/StringListView.java index 3a21a385..f157be3b 100644 --- a/helper/helper/src/main/java/com/linkedin/avroutil1/compatibility/collectiontransformer/StringListView.java +++ b/helper/helper/src/main/java/com/linkedin/avroutil1/compatibility/collectiontransformer/StringListView.java @@ -38,16 +38,30 @@ public String set(int index, String element) { return previousValue; } + public String set(int index, Utf8 element) { + String previousValue = String.valueOf(_utf8List.get(index)); + _utf8List.set(index, element); + return previousValue; + } + @Override public void add(int index, String element) { _utf8List.add(index, new Utf8(element)); } + public void add(int index, Utf8 element) { + _utf8List.add(index, element); + } + @Override public boolean add(String element) { return _utf8List.add(new Utf8(element)); } + public boolean add(Utf8 element) { + return _utf8List.add(element); + } + @Override public boolean addAll(int index, java.util.Collection c) { boolean modified = false; @@ -58,6 +72,30 @@ public boolean addAll(int index, java.util.Collection c) { return modified; } + /** + * Overloaded method to add all Utf8 elements of a collection at a specific index. + */ + public boolean addAll(int index, java.util.List c) { + boolean modified = false; + for (Utf8 element : c) { + _utf8List.add(index++, element); + modified = true; + } + return modified; + } + + /** + * Overloaded method to add all Utf8 elements of a set at a specific index. + */ + public boolean addAll(int index, java.util.Set c) { + boolean modified = false; + for (Utf8 element : c) { + _utf8List.add(index++, element); + modified = true; + } + return modified; + } + @Override public boolean remove(Object o) { return _utf8List.remove(new Utf8(o.toString()));