001package net.gdface.codegen.generic;
002
003import org.apache.commons.cli.Options;
004
005import net.gdface.cli.Context;
006import net.gdface.codegen.generator.Generator;
007import net.gdface.codegen.generator.GeneratorConfiguration;
008
009public class GenericGenerator extends Generator {
010
011        private final GenericInterfaceOptions options = GenericInterfaceOptions.getInstance();
012        private final GenericInferfaceConfiguration config = new GenericInferfaceConfiguration();
013
014        public GenericGenerator() {
015        }
016
017        @SuppressWarnings({ "unchecked", "rawtypes" })
018        @Override
019        public Context createEngineContext() {
020                GenericInterface newSourceInfo = new GenericInterface(config.getInterfaceClass(), config.getRefClass(), config.getShellInterface());
021                if (!newSourceInfo.compile()){
022                        System.exit(1);
023                }
024                Context context = super.createEngineContext();
025                context.setProperty(SOURCE_INFO, newSourceInfo);
026                return context;
027        }
028
029        @Override
030        protected Options getOptions() {
031                return options.getOptions();
032        }
033
034        protected GeneratorConfiguration getGeneratorConfiguration() {
035                return this.config;
036        }
037
038        public static void main(String[] args) {
039                new GenericGenerator().parseCommandLine(args).initEngine().generate();
040        }
041
042}