All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdc.mf.html.adaptors.ProfileAdaptor Maven / Gradle / Ivy

The newest version!
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.rules.Profile;
import cdc.issues.rules.Rule;
import cdc.mf.html.MfHtmlGenerationArgs;
import cdc.mf.html.MfParams;

public class ProfileAdaptor extends ObjectModelAdaptor {
    private final MfHtmlGenerationArgs args;

    public ProfileAdaptor(MfHtmlGenerationArgs args) {
        this.args = args;
    }

    @Override
    public synchronized Object getProperty(Interpreter interp,
                                           ST self,
                                           Profile profile,
                                           Object property,
                                           String propertyName) throws STNoSuchPropertyException {
        switch (propertyName) {
        case "rules":
            return profile.getRules().stream().sorted(Rule.ID_COMPARATOR).toList();
        case "kind":
            return "profile";
        case "displayName":
            return profile.getName();
        case "description":
            return MfParams.toHtml(profile.getDescription(), args);
        default:
            break;
        }

        return super.getProperty(interp, self, profile, property, propertyName);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy