BeanClassNameValidator { public void validate(Class<?> beanClass) { beanClasses.compute(Classes.className(beanClass), (key, previous) -> { if (previous != null && !previous.equals(beanClass)) throw new Error(format("found bean class with duplicate name which can be confusing, please use different class name, previousClass={}, class={}", previous.getCanonicalName(), beanClass.getCanonicalName())); return beanClass; }); }  void validate(Class<?> beanClass);  }
@Test void validate() { validator.beanClasses.put(Classes.className(TestBean.class), Void.class); assertThatThrownBy(() -> validator.validate(TestBean.class)) .isInstanceOf(Error.class).hasMessageContaining("found bean class with duplicate name"); }