001package org.nasdanika.html.ecore;
002
003import org.eclipse.emf.ecore.EAttribute;
004import org.eclipse.emf.ecore.EClass;
005import org.eclipse.emf.ecore.EDataType;
006import org.eclipse.emf.ecore.EEnum;
007import org.eclipse.emf.ecore.EEnumLiteral;
008import org.eclipse.emf.ecore.EOperation;
009import org.eclipse.emf.ecore.EPackage;
010import org.eclipse.emf.ecore.EParameter;
011import org.eclipse.emf.ecore.EReference;
012import org.eclipse.emf.ecore.EStructuralFeature;
013import org.eclipse.emf.ecore.EcorePackage;
014import org.nasdanika.common.Context;
015import org.nasdanika.emf.ComposedAdapterFactory;
016import org.nasdanika.emf.FunctionAdapterFactory;
017
018/**
019 * Provides adapters for the Ecore types - {@link EPackage}, {@link EClass}, {@link EStructuralFeature}, {@link EOperation}, ...
020 * @author Pavel
021 *
022 */
023public class EcoreActionSupplierAdapterFactory extends ComposedAdapterFactory {
024        
025        public EcoreActionSupplierAdapterFactory(
026                        Context context, 
027                        java.util.function.Function<EPackage,String> ePackagePathComputer,
028                        java.util.function.Function<String, String> javadocResolver) {
029                
030                // Registering adapter factories.
031                registerAdapterFactory(
032                        new FunctionAdapterFactory<EcoreActionSupplier, EPackage>(
033                                EcorePackage.Literals.EPACKAGE, 
034                                EcoreActionSupplier.class, 
035                                this.getClass().getClassLoader(), 
036                                e -> new EPackageActionSupplier(e, context, ePackagePathComputer)));    
037
038                registerAdapterFactory(
039                        new FunctionAdapterFactory<EcoreActionSupplier, EClass>(
040                                EcorePackage.Literals.ECLASS, 
041                                EcoreActionSupplier.class, 
042                                this.getClass().getClassLoader(), 
043                                e -> new EClassActionSupplier(e, context, ePackagePathComputer, javadocResolver, this::isGenerateLoadSpecification)));          
044
045                registerAdapterFactory(
046                        new FunctionAdapterFactory<EcoreActionSupplier, EDataType>(
047                                EcorePackage.Literals.EDATA_TYPE, 
048                                EcoreActionSupplier.class, 
049                                this.getClass().getClassLoader(), 
050                                e -> new EDataTypeActionSupplier(e, context, ePackagePathComputer, javadocResolver)));          
051
052                registerAdapterFactory(
053                        new FunctionAdapterFactory<EcoreActionSupplier, EEnum>(
054                                EcorePackage.Literals.EENUM, 
055                                EcoreActionSupplier.class, 
056                                this.getClass().getClassLoader(), 
057                                e -> new EEnumActionSupplier(e, context, ePackagePathComputer, javadocResolver)));              
058
059                registerAdapterFactory(
060                        new FunctionAdapterFactory<EcoreActionSupplier, EEnumLiteral>(
061                                EcorePackage.Literals.EENUM_LITERAL, 
062                                EcoreActionSupplier.class, 
063                                this.getClass().getClassLoader(), 
064                                e -> new EEnumLiteralActionSupplier(e, context, ePackagePathComputer)));                
065
066                registerAdapterFactory(
067                        new FunctionAdapterFactory<EcoreActionSupplier, EAttribute>(
068                                EcorePackage.Literals.EATTRIBUTE, 
069                                EcoreActionSupplier.class, 
070                                this.getClass().getClassLoader(), 
071                                e -> new EAttributeActionSupplier(e, context, ePackagePathComputer)));          
072
073                registerAdapterFactory(
074                        new FunctionAdapterFactory<EcoreActionSupplier, EReference>(
075                                EcorePackage.Literals.EREFERENCE, 
076                                EcoreActionSupplier.class, 
077                                this.getClass().getClassLoader(), 
078                                e -> new EReferenceActionSupplier(e, context, ePackagePathComputer)));          
079
080                registerAdapterFactory(
081                        new FunctionAdapterFactory<EcoreActionSupplier, EOperation>(
082                                EcorePackage.Literals.EOPERATION, 
083                                EcoreActionSupplier.class, 
084                                this.getClass().getClassLoader(), 
085                                e -> new EOperationActionSupplier(e, context, ePackagePathComputer)));          
086
087                registerAdapterFactory(
088                        new FunctionAdapterFactory<EcoreActionSupplier, EParameter>(
089                                EcorePackage.Literals.EPARAMETER, 
090                                EcoreActionSupplier.class, 
091                                this.getClass().getClassLoader(), 
092                                e -> new EParameterActionSupplier(e, context, ePackagePathComputer)));  
093        }
094        
095        /**
096         * Override to return false to suppress generation of load specification.
097         * @return
098         */
099        protected boolean isGenerateLoadSpecification() {
100                return true;
101        }
102
103}