Package com.clarkparsia.empire

Examples of com.clarkparsia.empire.EmpireException


   * @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);
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.clarkparsia.empire.EmpireException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.