### Question:
JPAPathBuilderValidator implements PathBuilderValidator { @Override public Class<?> validate(Class<?> parent, String property, Class<?> propertyType) { try { ManagedType managedType = metamodel.managedType(parent); Attribute attribute = managedType.getAttribute(property); if (attribute instanceof PluralAttribute) { return ((PluralAttribute) attribute).getElementType().getJavaType(); } else { return Primitives.wrap(attribute.getJavaType()); } } catch (IllegalArgumentException e) { return null; } } JPAPathBuilderValidator(EntityManager entityManager);  JPAPathBuilderValidator(Metamodel metamodel); @Override Class<?> validate(Class<?> parent, String property, Class<?> propertyType);  }### Answer:
@Test public void validate() { JPAPathBuilderValidator validator = new JPAPathBuilderValidator(entityManagerFactory.getMetamodel()); assertEquals(String.class, validator.validate(Cat.class, "name", String.class)); assertEquals(Cat.class, validator.validate(Cat.class, "kittens", Collection.class)); assertEquals(Cat.class, validator.validate(Cat.class, "mate", Cat.class)); assertNull(validator.validate(Cat.class, "xxx", String.class)); assertNull(validator.validate(Object.class, "name", String.class)); }