我试着在我正在创建的一系列对象上覆盖equals/hashCode,并使用Java 1.7开发一个接口/实用程序类.由于我不确定这种方法将如何执行,我将不胜感激任何反馈.我主要关注的是使用原始类型的自动装箱以及我将采取什么样的性能.
接口:
public interface Hashable {
/**
* Return the base offset for the {@link Object#hashCode()}, this number
* should be unique and odd;
*
* @return int
*/
public int getBaseOffset();
/**
* Return the base offset for the class fields{@link Object#hashCode()},
* this number should be unique and odd;
*
* @return int
*/
public int getFieldOffset();
/**
* Return an {@link Object} array of the fields to use for
* {@link Object#equals(Object)} and {@link Object#hashCode()}
* …Run Code Online (Sandbox Code Playgroud) java ×1