final ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(oid.getObjectSpecId());
final Object pojo = spec.createObject();
if(oid.isViewModel()) {
// initialize the view model pojo from the oid's identifier
final ViewModelFacet facet = spec.getFacet(ViewModelFacet.class);
if(facet == null) {
throw new IllegalArgumentException("spec does not have ViewModelFacet; " + oid.toString() + "; spec is " + spec.getFullIdentifier());
}
// a slight compromise? close enough.
if(!(oid instanceof RootOid)) {
throw new IllegalArgumentException("oid is view model but not a RootOid; " + oid.toString());
}
final RootOid rootOid = (RootOid) oid;
final String memento = rootOid.getIdentifier();
facet.initialize(pojo, memento);
}
return pojo;
}