Example #1
0
  protected void generateView(Map<String, org.ektorp.support.DesignDocument.View> views, Field f) {
    DocumentReferences referenceMetaData = f.getAnnotation(DocumentReferences.class);
    if (referenceMetaData == null) {
      LOG.warn("No DocumentReferences annotation found in field: ", f.getName());
      return;
    }

    if (referenceMetaData.view().length() > 0) {
      LOG.debug("Skipping view generation for field {} as view is already specified", f.getName());
      return;
    }

    if (Set.class.isAssignableFrom(f.getType())) {
      generateSetBasedDocRefView(views, f, referenceMetaData);
    } else {
      throw new ViewGenerationException(
          String.format(
              "The type of the field: %s in %s annotated with DocumentReferences is not supported. (Must be assignable from java.util.Set)",
              f.getName(), f.getDeclaringClass()));
    }
  }
Example #2
0
  protected void generateView(
      Map<String, org.ektorp.support.DesignDocument.View> views, Method me) {
    DocumentReferences referenceMetaData = me.getAnnotation(DocumentReferences.class);
    if (referenceMetaData == null) {
      LOG.warn("No DocumentReferences annotation found in method: ", me.getName());
      return;
    }
    if (!me.getName().startsWith("get")) {
      throw new ViewGenerationException(
          String.format(
              "The method: %s in %s annotated with DocumentReferences does not conform to the naming convention of 'getXxxx'",
              me.getName(), me.getDeclaringClass()));
    }

    if (Set.class.isAssignableFrom(me.getReturnType())) {
      generateSetBasedDocRefView(views, me, referenceMetaData);
    } else {
      throw new ViewGenerationException(
          String.format(
              "The return type of: %s in %s annotated with DocumentReferences is not supported. (Must be assignable from java.util.Set)",
              me.getName(), me.getDeclaringClass()));
    }
  }