All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hotrod.runtime.livesql.util.IdUtil Maven / Gradle / Ivy

There is a newer version: 4.8.1
Show newest version
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