org.stringtemplate.v4.misc.ObjectModelAdaptor Java Examples
The following examples show how to use
org.stringtemplate.v4.misc.ObjectModelAdaptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtensibleStCompiler.java From protostuff-compiler with Apache License 2.0 | 6 votes |
private void addPropertyExtensions(STGroup group, ExtensionProvider extensionProvider) { Map<Class<?>, PropertyProvider> extenderMap = extensionProvider.propertyProviders(); for (Map.Entry<Class<?>, PropertyProvider> entry : extenderMap.entrySet()) { Class<?> objectClass = entry.getKey(); PropertyProvider extender = entry.getValue(); group.registerModelAdaptor(objectClass, new ObjectModelAdaptor() { @Override public synchronized Object getProperty(Interpreter interp, ST self, Object o, Object property, String propertyName) { if (extender.hasProperty(propertyName)) { return extender.getProperty(o, propertyName); } return super.getProperty(interp, self, o, property, propertyName); } }); } }
Example #2
Source File: TemplateMaker.java From axelor-open-suite with GNU Affero General Public License v3.0 | 5 votes |
@Override public Object getProperty( Interpreter interp, ST self, Object o, Object property, String propertyName) { Property prop = this.getProperty(o.getClass(), (String) property); ModelAdaptor adap = self.groupThatCreatedThisInstance.getModelAdaptor(ObjectModelAdaptor.class); if (prop == null || Strings.isNullOrEmpty(prop.getSelection())) { return adap.getProperty(interp, self, o, property, propertyName); } Object value = adap.getProperty(interp, self, o, property, propertyName); return getSelectionValue(prop, o, value); }