com.softicar.platform.common.core.utils.equals.EqualsComparerBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
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);
}
}