Java Code Examples for org.stringtemplate.v4.misc.ObjectModelAdaptor

The following examples show how to use org.stringtemplate.v4.misc.ObjectModelAdaptor. These examples are extracted from open source projects. 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 Project: protostuff-compiler   Source File:    License: Apache License 2.0 6 votes vote down vote up
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() {
            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
public Object getProperty(
    Interpreter interp, ST self, Object o, Object property, String propertyName) {
  Property prop = this.getProperty(o.getClass(), (String) property);
  ModelAdaptor adap =

  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);