final String reasonDisabledIfAny = usability.getReason();
final DescribedAsFacet describedAsFacet = objectAction.getFacet(DescribedAsFacet.class);
final String descriptionIfAny = describedAsFacet != null? describedAsFacet.value(): null;
final CssClassFacet cssClassFacet = objectAction.getFacet(CssClassFacet.class);
final boolean blobOrClob = returnsBlobOrClob(objectAction);
final boolean prototype = isExplorationOrPrototype(objectAction);
final String actionIdentifier = actionIdentifierFor(objectAction);
Builder builder = newSubMenuItem(actionLabel)
.link(link)
.describedAs(descriptionIfAny)
.enabled(reasonDisabledIfAny)
.returnsBlobOrClob(blobOrClob)
.prototyping(prototype)
.withActionIdentifier(actionIdentifier);
if (cssClassFacet != null) {
builder.withCssClass(cssClassFacet.value());
}
return builder;
}