Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Threema/app/src/main/java/ch/threema/app/utils/     Datei vom 25.3.2026 mit Größe 2 kB image not shown  

Quelle  IdUtil.java

  Sprache: JAVA
 

package ch.threema.app.utils;

import java.util.HashMap;
import java.util.Map;

import androidx.annotation.NonNull;
import ch.threema.storage.models.group.GroupModelOld;

public class IdUtil {

    private static final Map<String, Integer> contactIds = new HashMap<>();
    private static final String KEY_CONTACT = "c-";
    private static final String KEY_GROUP = "g-";

    /**
     * Return a unique integer for the specified key.
     * <p>
     * The function always returns the same value for the same key as long as the app is
     * running. After an app restart (when the memory is cleared), a new value will be generated.
     * <p>
     * Currently the function is implemented with a sequential positive integer, so the first
     * contact will get the number 1, the second contact will get the number 2, and so on.
     */

    private static int getTempId(String key) {
        synchronized (contactIds) {
            if (!contactIds.containsKey(key)) {
                contactIds.put(key, contactIds.size() + 1);
            }
            return contactIds.get(key);
        }
    }

    /**
     * Return a unique integer for the specified contact.
     * <p>
     * The function always returns the same value for the same contact as long as the app is
     * running. After an app restart (when the memory is cleared), a new value will be generated.
     * <p>
     * Currently the function is implemented with a sequential positive integer, so the first
     * contact will get the number 1, the second contact will get the number 2, and so on.
     */

    public static int getContactTempId(@NonNull String identity) {
        return getTempId(KEY_CONTACT + identity);
    }

    /**
     * Return a unique integer for the specified group.
     * <p>
     * The function always returns the same value for the same group as long as the app is
     * running. After an app restart (when the memory is cleared), a new value will be generated.
     * <p>
     * Currently the function is implemented with a sequential positive integer, so the first
     * contact will get the number 1, the second contact will get the number 2, and so on.
     */

    public static int getGroupTempId(GroupModelOld group) {
        return getTempId(KEY_GROUP + group.getId());
    }
}

Messung V0.5 in Prozent
C=95 H=96 G=95

¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.