1 package org.simantics.scl.compiler.common.names;
3 import org.simantics.scl.compiler.internal.types.HashConsing;
5 public final class Name {
6 public static final Name[] EMPTY_ARRAY = new Name[0];
8 public final String module;
9 public final String name;
11 private Name(String module, String name) {
16 private static final HashConsing<Name> nameCache =
17 new HashConsing<Name>() {
18 protected boolean equals(Name a, Name b) {
19 return a.name.equals(b.name) && a.module.equals(b.module);
22 protected int hashCode(Name obj) {
23 return obj.module.hashCode()*31 + obj.name.hashCode();
27 public String toString() {
28 return module + "/" + name;
31 public static Name create(String module, String name) {
32 return nameCache.canonical(new Name(module, name));