class ObjectTypeValidator implements BiPredicate<Object, Object> {

    @Override
    public boolean test(@NonNull Object objectOne, @NonNull Object objectTwo) {
        ObjectTypeRetriever retriever = new ObjectTypeRetriever();
        return retriever.apply(objectOne).equals(retriever.apply(objectTwo));
    }

}

class ObjectTypeValidatorTest {

    @Test
    public void compareInvalidObjectAndClassThenReturnFalse() {

        boolean result = new ObjectTypeValidator().test(new A(), B.class);
        assertFalse(result);
    }

}