Пример #1
0
 private void fillResourceToCommentMap() {
   if (resourceToCommentMap != null) return;
   final Map<URI, String> newMap = new HashMap<URI, String>();
   for (Field field : this.getClass().getFields()) {
     try {
       final Object value = field.get(this);
       if (value instanceof URI) {
         final Comment comment = field.getAnnotation(Comment.class);
         if (comment != null) newMap.put((URI) value, comment.value());
       }
     } catch (IllegalAccessException iae) {
       throw new RuntimeException("Error while creating resource to comment map.", iae);
     }
   }
   resourceToCommentMap = newMap;
 }
Пример #2
0
 private boolean writeComment(final Field field, final int depth) {
   final boolean commentPresent = field.isAnnotationPresent(Comment.class);
   if (commentPresent) {
     final Comment comments = field.getAnnotation(Comment.class);
     for (String comment : comments.value()) {
       final String trimmed = comment.trim();
       if (trimmed.isEmpty()) {
         continue;
       }
       writeIndention(depth);
       writer.print("# ");
       writer.print(trimmed);
       writer.println();
     }
   }
   return commentPresent;
 }