Exemplo n.º 1
0
 private static LinkedHashMap<String, Prop> createProps() {
   Field[] fs = Configuration.class.getDeclaredFields();
   LinkedHashMap<String, Prop> res = new LinkedHashMap<String, Prop>();
   for (Field f : fs)
     if (!Modifier.isStatic(f.getModifiers())) {
       Description annotation = f.getAnnotation(Description.class);
       if (annotation != null) {
         String name = f.getName().replace('_', '.');
         res.put(name, new Prop(name, annotation.value(), f));
       }
     }
   return res;
 }
Exemplo n.º 2
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()));
    }
  }