mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-18 00:20:44 +00:00
Merge pull request #95 from Protonull/more-object-utils
Add MoreObjectUtils
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package vg.civcraft.mc.civmodcore.util;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Utility class that fills in the gaps of {@link ObjectUtils}.
|
||||
*
|
||||
* @author Protonull
|
||||
*/
|
||||
public final class MoreObjectUtils {
|
||||
|
||||
/**
|
||||
* Determines whether two things are equal based on their respective hash codes. This is obviously less accurate
|
||||
* than {@link Object#equals(Object)}, however this can be used to, for example, test if an object has been changed.
|
||||
*
|
||||
* @param <L> The left hand object type.
|
||||
* @param <R> The right hand object type.
|
||||
* @param lhs The left hand object.
|
||||
* @param rhs THe right hand object.
|
||||
* @return Returns whether the left hand and right hand objects have matching hashes.
|
||||
*/
|
||||
public static <L, R> boolean hashEquals(final L lhs, final R rhs) {
|
||||
return lhs == rhs || (!(lhs == null || rhs == null) && lhs.hashCode() == rhs.hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user