Skip to content

Commit fd8e133

Browse files
gusbroGustavo Brown Rodrigueziroqueta
authored
Add a generic parameter <E> to getExternalInstance (#986)
* Add a generic parameter <E> to getExternalInstance To avoid getting warning: [unchecked] unchecked cast when generated code uses this method. So now instead of being declared as public ArrayList getExternalInstance() it is declared as public <E> ArrayList<E> getExternalInstance() with <E> being the type parameter. You can then call the method passing an explicit parameter, e.g.: chatHistory.<OpenAIResponse.Message>getExternalInstance(); which we currently don't generate, but just using chatHistory.getExternalInstance(); also does not yield a warning. * Add generics ni array creation and cast in add method --------- Co-authored-by: Gustavo Brown Rodriguez <[email protected]> Co-authored-by: iroqueta <[email protected]>
1 parent b977075 commit fd8e133

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

common/src/main/java/com/genexus/GXExternalCollection.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ public Vector getStruct()
100100
}
101101

102102
@SuppressWarnings("unchecked")
103-
public ArrayList getExternalInstance() {
104-
ArrayList list = new ArrayList();
103+
public <E> ArrayList<E> getExternalInstance() {
104+
ArrayList<E> list = new ArrayList<>();
105105
for (T Item : this)
106106
{
107107
try
108108
{
109-
list.add(Item.getClass().getMethod("getExternalInstance", new Class[]{}).invoke(Item));
109+
list.add((E) Item.getClass().getMethod("getExternalInstance", new Class[]{}).invoke(Item));
110110
}
111111
catch (Exception e)
112112
{

0 commit comments

Comments
 (0)