LiferayObjectWrapper extends DefaultObjectWrapper { @Override public TemplateModel wrap(Object object) throws TemplateModelException { if (object == null) { return null; } if (object instanceof TemplateModel) { return (TemplateModel)object; } Class<?> clazz = object.getClass(); String className = clazz.getName(); if (className.startsWith("com.liferay.")) { if (object instanceof TemplateNode) { return new LiferayTemplateModel((TemplateNode)object, this); } if (object instanceof Collection) { return new SimpleSequence((Collection)object, this); } if (object instanceof Map) { return new MapModel((Map)object, this); } return _STRING_MODEL_FACTORY.create(object, this); } ModelFactory modelFactory = _modelFactories.get(clazz); if (modelFactory != null) { return modelFactory.create(object, this); } return super.wrap(object); } LiferayObjectWrapper(); @Override TemplateModel wrap(Object object);  }
@Test public void testWrap() throws Exception { testWrap(new LiferayObjectWrapper()); }