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

com.softicar.platform.common.core.utils.equals.EqualsComparerBase Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.core.utils.equals;

import com.softicar.platform.common.core.utils.CastUtils;
import java.io.Serializable;
import java.util.function.Function;

abstract class EqualsComparerBase implements IEqualsComparer, Serializable {

	@Override
	public boolean compareToObject(T thisObject, Object otherObject) {

		if (thisObject == otherObject) {
			return true;
		} else if (thisObject != null && otherObject != null) {
			Class thisClass = CastUtils.cast(thisObject.getClass());
			if (thisClass.isInstance(otherObject)) {
				return compare(thisObject, thisClass.cast(otherObject));
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

	@Override
	public  IEqualsComparer comparing(Function keyExtractor) {

		return comparing(new EqualsKeyExtractor<>(keyExtractor));
	}

	@Override
	public IEqualsComparer comparing(IEqualsComparer otherComparator) {

		return new EqualsComposer<>(this, otherComparator);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy