MongoClassValidator implements ClassVisitor { void validateEntityClass() { validator.validate(); if (id == null) { throw new Error("mongo entity class must have @Id field, class=" + validator.instanceClass.getCanonicalName()); } } MongoClassValidator(Class<?> entityClass); @Override void visitClass(Class<?> objectClass, String path); @Override void visitField(Field field, String parentPath); @Override void visitEnum(Class<?> enumClass);  }
@Test void validateEntityClass() { new MongoClassValidator(TestEntity.class).validateEntityClass(); }