@@ -0,0 +1,1439 @@
+package org.ccci.gto.android.common.support.v4.util;%0A%0Aimport android.support.annotation.NonNull;%0Aimport android.support.v4.util.LongSparseArray;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Apublic class IdUtils %7B%0A    // no need to use AtomicLong because it is only referenced in blocks synchronized on IDS_REVERSE%0A    private static volatile long NEXT_ID = 1;%0A    private static final LongSparseArray%3CObject%3E IDS = new LongSparseArray%3C%3E();%0A    private static final Map%3CObject, Long%3E IDS_REVERSE = new HashMap%3C%3E();%0A%0A    @NonNull%0A    @SuppressWarnings(%22unchecked%22)%0A    public static %3CT%3E T convertId(final long id) %7B%0A        synchronized (IDS) %7B%0A            return (T) IDS.get(id);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Convert an arbitrary object to a long id. The arbitrary objects are kept in an internal mapping table, so use%0A     * simple immutable objects only to prevent leaking memory.%0A     *%0A     * @param id  arbitrary object%0A     * @param %3CT%3E any simple immutable class%0A     * @return unique id for arbitrary object%0A     */%0A    public static %3CT%3E long convertId(@NonNull final T id) %7B%0A        synchronized (IDS_REVERSE) %7B%0A            Long rawId = IDS_REVERSE.get(id);%0A            if (rawId == null) %7B%0A                rawId = NEXT_ID++;%0A                synchronized (IDS) %7B%0A                    IDS.put(rawId, id);%0A                %7D%0A                IDS_REVERSE.put(id, rawId);%0A            %7D%0A            return rawId;%0A        %7D%0A    %7D%0A%7D%0A

create IdUtils for converting arbitrary objects to long ids