标签:long pac class zab ide span lang set turn
package org.rx.bean; import org.rx.Lazy; import org.rx.SystemException; import java.io.Serializable; import java.lang.reflect.Field; public abstract class NStruct implements Serializable { static final long serialVersionUID = 42L; private transient Lazy<Field[]> fields = new Lazy<>(() -> this.getClass().getDeclaredFields()); @Override public int hashCode() { StringBuilder hex = new StringBuilder(); for (Field field : fields.getValue()) { field.setAccessible(true); try { Object val = field.get(this); if (val != null) { hex.append(val.hashCode()); } } catch (IllegalAccessException ex) { throw SystemException.wrap(ex); } } return hex.toString().hashCode(); } @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof NStruct)) { return false; } NStruct struct = (NStruct) obj; return this.hashCode() == struct.hashCode(); } }
标签:long pac class zab ide span lang set turn
原文地址:http://www.cnblogs.com/Googler/p/7616274.html