All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commons.box.app.SafeKey Maven / Gradle / Ivy

The newest version!
package commons.box.app;

import commons.box.util.Types;

import java.util.Arrays;

/**
 * 用于 Cache 等环境的 Key 非序列化实现
 * 

* 基于构造参数数组的深度相等,另外 hashCode 在构造时已生成 */ public class SafeKey { private final Object[] objs; private final int hc; public SafeKey(Object... objs) { this.objs = (objs != null) ? objs : new Object[]{}; this.hc = Types.hc(this.objs); } public Object[] objs() { return objs; } public int hc() { return hc; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SafeKey qCacheKey = (SafeKey) o; return Arrays.deepEquals(objs, qCacheKey.objs); } @Override public int hashCode() { return this.hc; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy