* @param theClass the class to validate.
* @throws com.clarkparsia.empire.EmpireException if
*/
public static void assertValid(final Class theClass) throws EmpireException {
if (!isEmpireCompatible(theClass)) {
throw new EmpireException("Missing a required annotation (Entity & RdfsClass) or does not implement SupportsRdfId");
}
Collection<AccessibleObject> aAccessors = new HashSet<AccessibleObject>();
aAccessors.addAll(getAnnotatedFields(theClass));
aAccessors.addAll(getAnnotatedGetters(theClass, true));
for (AccessibleObject aObj : aAccessors) {
if (aObj.getAnnotation(OneToMany.class) != null ||
aObj.getAnnotation(ManyToMany.class) != null) {
Class aType = aObj instanceof Field
? ((Field)aObj).getType()
: ((Method)aObj).getReturnType();
if (!Collection.class.isAssignableFrom(aType)) {
throw new EmpireException("Using OneToMany or ManyToMany annotation on a non-collection field : " + theClass + "." + aType);
}
}
}
}