예제 #1
0
  @Override
  protected void check(
      final MappedClass mc, final MappedField mf, final Set<ConstraintViolation> ve) {
    if (mf.hasAnnotation(Reference.class)) {
      final Class realType = (mf.isSingleValue()) ? mf.getType() : mf.getSubClass();

      if (realType == null) {
        throw new MappingException("Type is null for this MappedField: " + mf);
      }

      if ((!realType.isInterface()
          && mc.getMapper().getMappedClass(realType).getIdField() == null)) {
        ve.add(
            new ConstraintViolation(
                Level.FATAL,
                mc,
                mf,
                getClass(),
                mf.getFullName()
                    + " is annotated as a @"
                    + Reference.class.getSimpleName()
                    + " but the "
                    + mf.getType().getName()
                    + " class is missing the @"
                    + Id.class.getSimpleName()
                    + " annotation"));
      }
    }
  }