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

com.g2forge.alexandria.java.identity.StandardIdentity Maven / Gradle / Ivy

There is a newer version: 0.0.18
Show newest version
package com.g2forge.alexandria.java.identity;

import java.util.Objects;

import com.g2forge.alexandria.java.core.iface.ISingleton;

/**
 * Standard implementation of {@link IIdentity} using the normal {@link Object#equals(Object)} and {@link Object#hashCode()} methods.
 *
 * @see SameIdentity
 * @see IIdentity#standard()
 */
public class StandardIdentity implements IIdentity, ISingleton {
	protected static final SameIdentity SINGLETON = new SameIdentity();

	public static SameIdentity create() {
		return SINGLETON;
	}

	@Override
	public boolean equals(Object _this, Object that) {
		return Objects.equals(_this, that);
	}

	@Override
	public int hashCode(Object _this) {
		return Objects.hashCode(_this);
	}

	@Override
	public String toString() {
		return "StandardIdentity";
	}
}