public static Comment createComment(
      ObjectFactory objectFactory,
      URI baseUri,
      Document doc,
      com.xpn.xwiki.api.Object xwikiComment,
      XWiki xwikiApi,
      Boolean withPrettyNames) {
    Comment comment = objectFactory.createComment();
    comment.setId(xwikiComment.getNumber());

    com.xpn.xwiki.api.Property property = xwikiComment.getProperty("author");
    if (property != null) {
      comment.setAuthor((String) property.getValue());
      if (withPrettyNames) {
        comment.setAuthorName(xwikiApi.getUserName((String) property.getValue(), false));
      }
    }

    property = xwikiComment.getProperty("date");
    if (property != null) {
      Calendar calendar = Calendar.getInstance();
      calendar.setTime((Date) property.getValue());
      comment.setDate(calendar);
    }

    property = xwikiComment.getProperty("highlight");
    if (property != null) {
      comment.setHighlight((String) property.getValue());
    }

    property = xwikiComment.getProperty("comment");
    if (property != null) {
      comment.setText((String) property.getValue());
    }

    property = xwikiComment.getProperty("replyto");
    if (property != null) {
      comment.setReplyTo((Integer) property.getValue());
    }

    String pageUri = uri(baseUri, PageResource.class, doc.getWiki(), doc.getSpace(), doc.getName());
    Link pageLink = objectFactory.createLink();
    pageLink.setHref(pageUri);
    pageLink.setRel(Relations.PAGE);
    comment.getLinks().add(pageLink);

    return comment;
  }
  public static Class createClass(
      ObjectFactory objectFactory,
      URI baseUri,
      String wikiName,
      com.xpn.xwiki.api.Class xwikiClass) {
    Class clazz = objectFactory.createClass();
    clazz.setId(xwikiClass.getName());
    clazz.setName(xwikiClass.getName());

    for (java.lang.Object xwikiPropertyClassObject : xwikiClass.getProperties()) {
      PropertyClass xwikiPropertyClass = (PropertyClass) xwikiPropertyClassObject;

      Property property = objectFactory.createProperty();
      property.setName(xwikiPropertyClass.getName());
      property.setType(xwikiPropertyClass.getxWikiClass().getName());

      for (java.lang.Object xwikiPropertyObject : xwikiPropertyClass.getProperties()) {
        com.xpn.xwiki.api.Property xwikiProperty = (com.xpn.xwiki.api.Property) xwikiPropertyObject;
        java.lang.Object value = xwikiProperty.getValue();

        Attribute attribute = objectFactory.createAttribute();
        attribute.setName(xwikiProperty.getName());

        if (value != null) {
          attribute.setValue(value.toString());
        } else {
          attribute.setValue("");
        }

        property.getAttributes().add(attribute);
      }

      String propertyUri =
          uri(
              baseUri,
              ClassPropertyResource.class,
              wikiName,
              xwikiClass.getName(),
              xwikiPropertyClass.getName());
      Link propertyLink = objectFactory.createLink();
      propertyLink.setHref(propertyUri);
      propertyLink.setRel(Relations.SELF);
      property.getLinks().add(propertyLink);

      clazz.getProperties().add(property);
    }

    String classUri = uri(baseUri, ClassResource.class, wikiName, xwikiClass.getName());
    Link classLink = objectFactory.createLink();
    classLink.setHref(classUri);
    classLink.setRel(Relations.SELF);
    clazz.getLinks().add(classLink);

    String propertiesUri =
        uri(baseUri, ClassPropertiesResource.class, wikiName, xwikiClass.getName());
    Link propertyLink = objectFactory.createLink();
    propertyLink.setHref(propertiesUri);
    propertyLink.setRel(Relations.PROPERTIES);
    clazz.getLinks().add(propertyLink);

    String objectsUri =
        uri(baseUri, AllObjectsForClassNameResource.class, wikiName, xwikiClass.getName());
    Link objectsLink = objectFactory.createLink();
    objectsLink.setHref(objectsUri);
    objectsLink.setRel(Relations.OBJECTS);
    clazz.getLinks().add(objectsLink);

    return clazz;
  }