org.hotrod.runtime.livesql.util.IdUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hotrod-livesql Show documentation
Show all versions of hotrod-livesql Show documentation
HotRod is an ORM for Java, Spring and SpringBoot.
package org.hotrod.runtime.livesql.util;
import java.util.HashMap;
import java.util.Map;
public class IdUtil {
private static Map ids = new HashMap<>();
public static int id(final Object o) {
if (o == null) {
return 0;
}
Integer hc = Integer.valueOf(System.identityHashCode(o));
if (ids.containsKey(hc)) {
return ids.get(hc);
} else {
int n = ids.size() + 1;
ids.put(hc, n);
return n;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy