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(); }
/** * Returns the provided {@link Facet facet} as an {@link ImperativeFacet} if it either is one or * if it is a {@link DecoratingFacet} that in turn wraps an {@link ImperativeFacet}. * * <p>Otherwise, returns <tt>null</tt>. */ public static ImperativeFacet getImperativeFacet(final Facet facet) { if (facet instanceof ImperativeFacet) { return (ImperativeFacet) facet; } if (facet.getUnderlyingFacet() instanceof ImperativeFacet) { return (ImperativeFacet) facet.getUnderlyingFacet(); } if (facet instanceof DecoratingFacet) { final DecoratingFacet<?> decoratingFacet = ObjectExtensions.asT(facet); return getImperativeFacet(decoratingFacet.getDecoratedFacet()); } return null; }
private static String interpretFacet(final Facet facet) { if (facet == null || facet.isNoop()) { return ""; } if (facet instanceof ImperativeFacet) { ImperativeFacet imperativeFacet = (ImperativeFacet) facet; return imperativeFacet.getMethods().get(0).getName(); } final String name = facet.getClass().getSimpleName(); if (ignore(name)) { return ""; } final String abbr = StringExtensions.toAbbreviation(name); return abbr.length() > 0 ? abbr : name; }
private boolean isNotANoopFacet(final Facet facet) { return facet != null && !facet.isNoop(); }