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

org.javers.core.metamodel.type.TokenType Maven / Gradle / Ivy

There is a newer version: 7.6.1
Show newest version
package org.javers.core.metamodel.type;

import java.lang.reflect.TypeVariable;
import java.util.Objects;

public class TokenType extends JaversType {
    TokenType(TypeVariable baseJavaType) {
        super(baseJavaType);
    }

    @Override
    public boolean canBePrototype() {
        return false;
    }

    @Override
    public boolean isInstance(Object cdo) {
        return false;
    }

    public boolean equals(Object left, Object right) {
        return mathFriendlyEquals(left, right);
    }

    /**
     * Delegates to Objects.equals(a, b) in most cases.
     * Compares Long and Integer mathematically.
     */
    static boolean mathFriendlyEquals(Object a, Object b) {
        if (a instanceof Long && b instanceof Integer) {
            return ((Long) a).intValue() == ((Integer) b).intValue();
        }

        if (b instanceof Long && a instanceof Integer) {
            return ((Long) b).intValue() == ((Integer) a).intValue();
        }

        return Objects.equals(a, b);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy