1 /* 2 * Copyright (C) 2016 Uwe Plonus 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 package org.sw4j.tool.annotation.jpa.generator; 18 19 import java.io.IOException; 20 import java.util.Properties; 21 import javax.annotation.Nonnull; 22 import javax.annotation.processing.ProcessingEnvironment; 23 import org.sw4j.tool.annotation.jpa.generator.model.Model; 24 25 /** 26 * The {@code GeneratorService} is a service interface to output a model into a generic format. 27 * 28 * @author Uwe Plonus 29 */ 30 public interface GeneratorService { 31 32 /** 33 * Returns the prefix used by the implementing generator. 34 * 35 * @return the prefix of the generator. 36 */ 37 @Nonnull 38 String getPrefix(); 39 40 /** 41 * Sets the the properties of the generator. The properties are used to configure the generator. The 42 * recognized properties are generator dependent and must be described at the generator. 43 * 44 * @param properties the properties used to configure the generator. 45 */ 46 void setProperties(@Nonnull Properties properties); 47 48 /** 49 * Flag to indicate that the generator can process a model. For this the generator should be able to read the 50 * properties file and process all needed properties. 51 * 52 * @return {@code true} if the properties file can be read and the generator can process a model. 53 */ 54 boolean canProcess(); 55 56 /** 57 * The model to process and to output. 58 * 59 * @param model the model to process. 60 * @param processingEnv the processing environment used to emit messages. 61 * @throws IOException if the output cannot be written. 62 */ 63 void process(@Nonnull Model model, @Nonnull final ProcessingEnvironment processingEnv) throws IOException; 64 65 }