@Programmatic @SuppressWarnings("unchecked") @Override public <T> T newViewModelInstance(Class<T> ofClass, String memento) { final ObjectSpecification spec = specificationLoader.loadSpecification(ofClass); if (!spec.containsFacet(ViewModelFacet.class)) { throw new IsisException("Type must be a ViewModel: " + ofClass); } final ObjectAdapter adapter = persistenceSessionServiceInternal.createViewModelInstance(spec, memento); if (adapter.getOid().isViewModel()) { return (T) adapter.getObject(); } else { throw new IsisException( "Object instantiated but was not given a ViewModel Oid; please report as a possible defect in Isis: " + ofClass); } }
public boolean isForValueType(final Class<? extends Facet> cls) { final ObjectSpecification specification = content.getSpecification(); return specification != null && specification.containsFacet(cls); }