通用InternPool T在Java中?

通用InternPool T在Java中?

问题描述:

如何用Java编写通用的InternPool<T>?是否需要Internable接口?

How would I write a generic InternPool<T> in Java? Does it need a Internable interface?

String具有实习功能;我想实习像BigDecimalAccount这样的类.

String in Java has interning capabilities; I want to intern classes like BigDecimal and Account.

例如,请查看Interner rel ="nofollow noreferrer">番石榴. 不需要不需要Internable接口,它仅依赖于equalshashCode.

For an example take a look at Interner from Guava. It does not require an Internable interface, it just relies on equals and hashCode.