@Override
  public void debugData(final DebugBuilder debug) {
    facetDecoratorSet.debugData(debug);
    debug.appendln();

    debug.appendTitle("Specifications");
    final List<ObjectSpecification> specs = Lists.newArrayList(allSpecifications());
    Collections.sort(specs, ObjectSpecification.COMPARATOR_SHORT_IDENTIFIER_IGNORE_CASE);
    for (final ObjectSpecification spec : specs) {
      StringBuffer str = new StringBuffer();
      str.append(spec.isAbstract() ? "A" : ".");
      str.append(spec.isService() ? "S" : ".");
      str.append(ChoicesFacetUtils.hasChoices(spec) ? "B" : ".");
      str.append(spec.isParentedOrFreeCollection() ? "C" : ".");
      str.append(spec.isNotCollection() ? "O" : ".");
      str.append(spec.isParseable() ? "P" : ".");
      str.append(spec.isEncodeable() ? "E" : ".");
      str.append(spec.isValueOrIsParented() ? "A" : ".");

      final boolean hasIdentity =
          !(spec.isParentedOrFreeCollection() || spec.isParented() || spec.isValue());
      str.append(hasIdentity ? "I" : ".");
      str.append("  ");
      str.append(spec.getFullIdentifier());

      debug.appendPreformatted(spec.getShortIdentifier(), str.toString());
    }
  }
Exemple #2
0
  public static void specification(
      final ObjectSpecification specification, final DebugBuilder debugBuilder) {
    try {
      debugBuilder.appendTitle(specification.getClass().getName());
      debugBuilder.appendAsHexln("Hash code", specification.hashCode());
      debugBuilder.appendln("ID", specification.getIdentifier());
      debugBuilder.appendln("Full Name", specification.getFullIdentifier());
      debugBuilder.appendln("Short Name", specification.getShortIdentifier());
      debugBuilder.appendln("Singular Name", specification.getSingularName());
      debugBuilder.appendln("Plural Name", specification.getPluralName());
      debugBuilder.appendln("Description", specification.getDescription());
      debugBuilder.blankLine();
      debugBuilder.appendln("Features", featureList(specification));
      debugBuilder.appendln(
          "Type", specification.isParentedOrFreeCollection() ? "Collection" : "Object");
      if (specification.superclass() != null) {
        debugBuilder.appendln("Superclass", specification.superclass().getFullIdentifier());
      }
      debugBuilder.appendln("Interfaces", specificationNames(specification.interfaces()));
      debugBuilder.appendln("Subclasses", specificationNames(specification.subclasses()));
      debugBuilder.blankLine();
      debugBuilder.appendln("Service", specification.isService());
      debugBuilder.appendln("Encodable", specification.isEncodeable());
      debugBuilder.appendln("Parseable", specification.isParseable());
      debugBuilder.appendln("Aggregated", specification.isValueOrIsParented());
    } catch (final RuntimeException e) {
      debugBuilder.appendException(e);
    }

    if (specification instanceof DebuggableWithTitle) {
      ((DebuggableWithTitle) specification).debugData(debugBuilder);
    }

    debugBuilder.blankLine();

    debugBuilder.appendln("Facets");
    final Class<? extends Facet>[] facetTypes = specification.getFacetTypes();
    debugBuilder.indent();
    if (facetTypes.length == 0) {
      debugBuilder.appendln("none");
    } else {
      for (final Class<? extends Facet> type : facetTypes) {
        final Facet facet = specification.getFacet(type);
        debugBuilder.appendln(facet.toString());
      }
    }
    debugBuilder.unindent();
    debugBuilder.blankLine();

    debugBuilder.appendln("Fields");
    debugBuilder.indent();
    specificationFields(specification, debugBuilder);
    debugBuilder.unindent();

    debugBuilder.appendln("Object Actions");
    debugBuilder.indent();
    specificationActionMethods(specification, debugBuilder);
    debugBuilder.unindent();
  }