private void addValue() {
final ObjectAdapter valueAdapter = objectMember.get(objectAdapter);
// use the runtime type if we have a value, else the compile time type of the member otherwise
final ObjectSpecification spec = valueAdapter != null? valueAdapter.getSpecification(): objectMember.getSpecification();
final ValueFacet valueFacet = spec.getFacet(ValueFacet.class);
if (valueFacet != null) {
JsonValueEncoder.appendValueAndFormat(spec, valueAdapter, representation);
return;
}
final RenderFacet renderFacet = objectMember.getFacet(RenderFacet.class);
boolean eagerlyRender = renderFacet != null && renderFacet.value() == Type.EAGERLY && rendererContext.canEagerlyRender(valueAdapter);
if(valueAdapter == null) {
representation.mapPut("value", NullNode.getInstance());
} else {
final TitleFacet titleFacet = spec.getFacet(TitleFacet.class);
final String title = titleFacet.title(valueAdapter, rendererContext.getLocalization());
final LinkBuilder valueLinkBuilder = DomainObjectReprRenderer.newLinkToBuilder(rendererContext, Rel.VALUE, valueAdapter).withTitle(title);
if(eagerlyRender) {
final DomainObjectReprRenderer renderer = new DomainObjectReprRenderer(rendererContext, getLinkFollowSpecs(), JsonRepresentation.newMap());