cdc.mf.html.adaptors.LocationAdaptor Maven / Gradle / Ivy
package cdc.mf.html.adaptors;
import org.stringtemplate.v4.Interpreter;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.misc.ObjectModelAdaptor;
import org.stringtemplate.v4.misc.STNoSuchPropertyException;
import cdc.issues.locations.Location;
import cdc.mf.html.MfHtmlGenerationArgs;
import cdc.mf.model.MfLocation;
public class LocationAdaptor extends ObjectModelAdaptor {
private final MfHtmlGenerationArgs args;
public LocationAdaptor(MfHtmlGenerationArgs args) {
this.args = args;
}
@Override
public synchronized Object getProperty(Interpreter interp,
ST self,
Location location,
Object property,
String propertyName) throws STNoSuchPropertyException {
switch (propertyName) {
case "element":
if (location instanceof final MfLocation loc) {
return loc.resolve(args.getModel()).orElse(args.getModel());
}
break;
case "parts":
if (location instanceof final MfLocation loc) {
return loc.getParts();
}
break;
default:
break;
}
return super.getProperty(interp, self, location, property, propertyName);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy