
org.nasdanika.html.model.html.gen.HtmlElementAdapter Maven / Gradle / Ivy
package org.nasdanika.html.model.html.gen;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.nasdanika.common.BiSupplier;
import org.nasdanika.common.Context;
import org.nasdanika.common.Function;
import org.nasdanika.common.FunctionFactory;
import org.nasdanika.common.ListCompoundSupplierFactory;
import org.nasdanika.common.MapCompoundSupplierFactory;
import org.nasdanika.common.ProgressMonitor;
import org.nasdanika.emf.EObjectAdaptable;
import org.nasdanika.html.Container;
import org.nasdanika.html.model.html.HtmlPackage;
/**
* Base class for HTML Element adapters providing common functionality
* @author Pavel
*
* @param
* @param
*/
public abstract class HtmlElementAdapter> extends AdapterImpl {
protected HtmlElementAdapter(M htmlElement) {
setTarget(htmlElement);
}
/**
* Creates a function which configures the element and returns it.
* This implementation applies attributes and adds content. Override to implement additional configuration.
* You may chain configuration functions with .then
* @param context
* @return
* @throws Exception
*/
protected Function createConfigureFunction(Context context) throws Exception {
MapCompoundSupplierFactory attributesFactory = new MapCompoundSupplierFactory<>("Attributes");
for (Entry ae: getTarget().getAttributes()) {
EObject value = ae.getValue();
attributesFactory.put(ae.getKey(), EObjectAdaptable.adaptToSupplierFactoryNonNull(value, Object.class));
}
ListCompoundSupplierFactory
© 2015 - 2025 Weber Informatics LLC | Privacy Policy