AttributeKey extends UniqueName { @SuppressWarnings("unchecked") public static <T> AttributeKey<T> valueOf(String name) { checkNotNull(name, "name"); AttributeKey<T> option = names.get(name); if (option == null) { option = new AttributeKey<T>(name); AttributeKey<T> old = names.putIfAbsent(name, option); if (old != null) { option = old; } } return option; } @Deprecated  AttributeKey(String name); @SuppressWarnings("unchecked") static AttributeKey<T> valueOf(String name); static boolean exists(String name); @SuppressWarnings("unchecked") static AttributeKey<T> newInstance(String name);  }
@Test public void testValueOf() { String name = "test1"; assertFalse(AttributeKey.exists(name)); AttributeKey<String> attr = AttributeKey.valueOf(name); AttributeKey<String> attr2 = AttributeKey.valueOf(name); assertSame(attr, attr2); }