Skip to content

feature(Android): add GxHashMap in Android for Dictionary data type#1118

Open
fpanizza wants to merge 6 commits into
masterfrom
feature/android/AddDictionary
Open

feature(Android): add GxHashMap in Android for Dictionary data type#1118
fpanizza wants to merge 6 commits into
masterfrom
feature/android/AddDictionary

Conversation

@fpanizza
Copy link
Copy Markdown
Contributor

@fpanizza fpanizza commented May 22, 2026

Problem

Android Offline Generator - Error compilando SDTs con Dictionary
https://issues.genexus.dev/viewissue.aspx?208671

Solution

Add GxHashMap in android for dictionary implementation.

Necesario para el cambio en el generador offline,
https://github.com/VY-GEN032-KG/genexus-suite-legacy/pull/1986

@genexusbot
Copy link
Copy Markdown
Collaborator

Cherry pick to beta success

@genexusbot
Copy link
Copy Markdown
Collaborator

Cherry pick to beta success

@genexusbot
Copy link
Copy Markdown
Collaborator

Cherry pick to beta success

@genexusbot
Copy link
Copy Markdown
Collaborator

Cherry pick to beta success

@genexusbot
Copy link
Copy Markdown
Collaborator

Cherry pick to beta success

…lization.

Resolve value types consistently in fromJson by detecting valueClass from first element or prior put(). Emulate Jackson behavior.
@genexusbot
Copy link
Copy Markdown
Collaborator

Cherry pick to beta success

@fpanizza fpanizza requested a review from jotapeg June 2, 2026 14:00

public boolean removeKey(K key) {
if (containsKey(key)) {
if (remove(key) != null)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El valor asociado a la clave podría ser null y en ese caso este método retorna false. Entiendo que debería devolver true si alguna clave fue removida.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cierto , fixed

for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
K key;
if (isNumberKey) {
key = (K) java.text.NumberFormat.getInstance().parse(entry.getKey());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Este NumberFormat.getInstance() usa el locale del dispositivo para el separador de decimales, pero JSON usa siempre el punto, por lo que la key podría resultar en un valor que luego dé error de parseo. Habría que usar los métodos de parsing "comunes" (valueOf) de los tipos de datos numéricos.


public V put(K key, V value) {
if (key instanceof Number)
isNumberKey = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isNumberKey nunca se resetea a false. No sé si es posible que el tipo de datos de la clave cambie sobre la misma instancia o no. En caso de que no, se puede desestimar este comentario.

return gson.toJson(this);
}
catch (Exception e) {
AndroidLog.error("Could not obtain json form Dictionary "+ e.getMessage());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"from" en vez de "form":


public void fromJson(String json) {
try {
this.clear();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Está bien este clear() al inicio independientemente de que el parseo tire o no una excepción? Si algo falla más abajo, el mapa queda vacío/corrupto con los datos nuevos a medias.

return convertToCharRest(this, true);
}

private GXHashMap<K, String> convertToCharRest(GXHashMap<K, V> thisHashMap, boolean isDateTime) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El primer parámetro que recibe este método es siempre this. Mejor quitarlo y simplemente iterar sobre entrySet().

@fpanizza fpanizza changed the title feature(Android): add GxHashMAp in Android for Dictionary data type feature(Android): add GxHashMap in Android for Dictionary data type Jun 3, 2026
@fpanizza
Copy link
Copy Markdown
Contributor Author

fpanizza commented Jun 3, 2026

Aclaro que la mayoria de tus comentarios vienen de la version de java , que migre a Gson solamente
https://github.com/genexuslabs/JavaClasses/blob/master/java/src/main/java/com/genexus/util/GXHashMap.java

De cualquier manera las miro 1 a 1 para dejarlo lo mejor posible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants