Package org.nuiton.eugene
Class AbstractGenerator<M extends Model>
- java.lang.Object
-
- org.nuiton.eugene.Template<M>
-
- org.nuiton.eugene.AbstractGenerator<M>
-
- Type Parameters:
M
- type of Model
- All Implemented Interfaces:
TemplateConfiguration
- Direct Known Subclasses:
AbstractMetaTransformer
,ObjectModelGenerator
,StateModelGenerator
public abstract class AbstractGenerator<M extends Model> extends Template<M>
AbstractGenerator Created: 28 oct. 2009- Author:
- Florian Desbois - desbois@codelutin.com
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractGenerator<M>
parent
-
Fields inherited from class org.nuiton.eugene.Template
configuration, excludeTemplates, generatedPackages, model, resourcesHelper
-
Fields inherited from interface org.nuiton.eugene.TemplateConfiguration
PROP_CLASS_LOADER, PROP_DEFAULT_PACKAGE, PROP_ENCODING, PROP_EXCLUDE_TEMPLATES, PROP_GENERATED_PACKAGES, PROP_LAST_MODIFIED_SOURCE, PROP_OVERWRITE, PROP_VERBOSE, PROP_WRITER_REPORT
-
-
Constructor Summary
Constructors Constructor Description AbstractGenerator()
AbstractGenerator(AbstractGenerator<M> parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canGeneratePackage(String packageName)
Test if given package is allowed for generation.protected File
getDestinationFile(File destDir, String filename)
String
getEncoding()
long
getLastModifiedSource()
String
getProperty(String name)
<V> V
getProperty(String key, Class<V> type)
protected Writer
getWriter(File outputFile)
protected boolean
isNewerThanSource(File file)
boolean
isOverwrite()
void
setParent(AbstractGenerator<M> parent)
protected void
write(File outputFile, MonitorWriter out)
-
Methods inherited from class org.nuiton.eugene.Template
applyTemplate, getClassLoader, getConfiguration, getExcludeTemplates, getGeneratedPackages, getModel, getOverwrite, getProperties, getResourcesHelper, getWriterReport, isVerbose, setConfiguration, setProperty
-
-
-
-
Field Detail
-
parent
protected AbstractGenerator<M extends Model> parent
-
-
Constructor Detail
-
AbstractGenerator
public AbstractGenerator()
-
AbstractGenerator
public AbstractGenerator(AbstractGenerator<M> parent)
-
-
Method Detail
-
setParent
public void setParent(AbstractGenerator<M> parent)
-
isOverwrite
public boolean isOverwrite()
- Specified by:
isOverwrite
in interfaceTemplateConfiguration
- Overrides:
isOverwrite
in classTemplate<M extends Model>
- Returns:
true
if must regenerate files even if they are up to date
-
getEncoding
public String getEncoding()
- Specified by:
getEncoding
in interfaceTemplateConfiguration
- Overrides:
getEncoding
in classTemplate<M extends Model>
- Returns:
- encoding to use to read and write files
-
getProperty
public String getProperty(String name)
- Specified by:
getProperty
in interfaceTemplateConfiguration
- Overrides:
getProperty
in classTemplate<M extends Model>
-
getLastModifiedSource
public long getLastModifiedSource()
- Specified by:
getLastModifiedSource
in interfaceTemplateConfiguration
- Overrides:
getLastModifiedSource
in classTemplate<M extends Model>
-
getProperty
public <V> V getProperty(String key, Class<V> type)
- Specified by:
getProperty
in interfaceTemplateConfiguration
- Overrides:
getProperty
in classTemplate<M extends Model>
-
isNewerThanSource
protected boolean isNewerThanSource(File file)
- Parameters:
file
- fichier a tester- Returns:
- vrai si le fichier passé en parametre est plus recent que les sources sur generateur.
-
canGeneratePackage
protected boolean canGeneratePackage(String packageName)
Test if given package is allowed for generation. An element can be generated if his package is in theTemplate.generatedPackages
list or ifTemplate.generatedPackages
is null or empty.- Parameters:
packageName
- package name to test- Returns:
- generation allowed
-
write
protected void write(File outputFile, MonitorWriter out)
-
getWriter
protected Writer getWriter(File outputFile) throws IOException
- Throws:
IOException
-
-