public class GenericExporter extends Object
GenericExporter
provides query type serialization logic for cases where APT annotation processors
can't be used. GenericExporter
scans the classpath for classes annotated with specified annotations
in specific packages and mirrors them into Querydsl expression types.
Example with Querydsl annotations:
GenericExporter exporter = new GenericExporter();
exporter.setTargetFolder(new File("target/generated-sources/java"));
exporter.export(com.example.domain.Entity.class.getPackage());
Example with JPA annotations:
GenericExporter exporter = new GenericExporter();
exporter.setKeywords(Keywords.JPA);
exporter.setEntityAnnotation(Entity.class);
exporter.setEmbeddableAnnotation(Embeddable.class);
exporter.setEmbeddedAnnotation(Embedded.class);
exporter.setSupertypeAnnotation(MappedSuperclass.class);
exporter.setSkipAnnotation(Transient.class);
exporter.setTargetFolder(new File("target/generated-sources/java"));
exporter.export(com.example.domain.Entity.class.getPackage());
Constructor and Description |
---|
GenericExporter()
Create a GenericExporter instance using the context classloader and default charset
|
GenericExporter(Charset charset)
Create a GenericExporter instance using the context classloader and the given charset
|
GenericExporter(ClassLoader classLoader)
Create a GenericExporter instance using the given classloader and default charset
|
GenericExporter(ClassLoader classLoader,
Charset charset)
Create a GenericExporter instance using the given classloader and charset for serializing
source files
|
Modifier and Type | Method and Description |
---|---|
void |
addAnnotationHelper(AnnotationHelper annotationHelper)
Add a annotation helper object to process custom annotations
|
void |
addStopClass(Class<?> cl)
Add a stop class to be used (default Object.class and Enum.class)
|
void |
export(Class<?>... classes)
Export the given classes
|
void |
export(Package... packages)
Export the given packages
|
void |
export(String... packages)
Export the given packages
|
Set<File> |
getGeneratedFiles()
Return the set of generated files
|
void |
setCreateScalaSources(boolean createScalaSources)
Set whether Scala sources are generated
|
void |
setEmbeddableAnnotation(Class<? extends Annotation> embeddableAnnotation)
Set the embeddable annotation
|
void |
setEmbeddedAnnotation(Class<? extends Annotation> embeddedAnnotation)
Set the embedded annotation
|
void |
setEntityAnnotation(Class<? extends Annotation> entityAnnotation)
Set the entity annotation
|
void |
setHandleFields(boolean b)
Deprecated.
Use
setPropertyHandling(PropertyHandling) instead |
void |
setHandleMethods(boolean b)
Deprecated.
Use
setPropertyHandling(PropertyHandling) instead |
void |
setKeywords(Collection<String> keywords)
Set the keywords to be used
|
void |
setNamePrefix(String prefix)
Set the name prefix
|
void |
setNameSuffix(String suffix)
Set the name suffix
|
void |
setPackageSuffix(String suffix)
Set the package suffix
|
void |
setPropertyHandling(PropertyHandling propertyHandling)
Set the property handling mode
|
void |
setSerializerClass(Class<? extends Serializer> serializerClass)
Set the serializer class to be used
|
void |
setSerializerConfig(SerializerConfig serializerConfig)
Set the serializer configuration to use
|
void |
setSkipAnnotation(Class<? extends Annotation> skipAnnotation)
Set the skip annotation
|
void |
setStrictMode(boolean s)
Set whether annotationless superclasses are handled or not (default: true)
|
void |
setSupertypeAnnotation(Class<? extends Annotation> supertypeAnnotation)
Set the supertype annotation
|
void |
setTargetFolder(File targetFolder)
Set the target folder for generated sources
|
void |
setTypeMappingsClass(Class<? extends TypeMappings> typeMappingsClass)
Set the typemappings class to be used
|
void |
setUseFieldTypes(boolean b)
Set whether field types should be used instead of getter return types (default false)
|
public GenericExporter(ClassLoader classLoader, Charset charset)
classLoader
- classloader to usecharset
- charset of target sourcespublic GenericExporter(ClassLoader classLoader)
classLoader
- classloader to usepublic GenericExporter(Charset charset)
charset
- charset of target sourcespublic GenericExporter()
public void export(Package... packages)
packages
- packages to be scannedpublic void export(String... packages)
packages
- packages to be scannedpublic void export(Class<?>... classes)
classes
- classes to be scannedpublic Set<File> getGeneratedFiles()
public void setEntityAnnotation(Class<? extends Annotation> entityAnnotation)
entityAnnotation
- entity annotationpublic void setSupertypeAnnotation(Class<? extends Annotation> supertypeAnnotation)
supertypeAnnotation
- supertype annotationpublic void setEmbeddableAnnotation(Class<? extends Annotation> embeddableAnnotation)
embeddableAnnotation
- embeddable annotationpublic void setEmbeddedAnnotation(Class<? extends Annotation> embeddedAnnotation)
embeddedAnnotation
- embedded annotationpublic void setSkipAnnotation(Class<? extends Annotation> skipAnnotation)
skipAnnotation
- skip annotationpublic void setTargetFolder(File targetFolder)
targetFolder
- public void setSerializerClass(Class<? extends Serializer> serializerClass)
serializerClass
- public void setTypeMappingsClass(Class<? extends TypeMappings> typeMappingsClass)
typeMappingsClass
- public void setCreateScalaSources(boolean createScalaSources)
createScalaSources
- public void setKeywords(Collection<String> keywords)
keywords
- public void setNamePrefix(String prefix)
prefix
- public void setNameSuffix(String suffix)
suffix
- public void setPackageSuffix(String suffix)
suffix
- @Deprecated public void setHandleFields(boolean b)
setPropertyHandling(PropertyHandling)
insteadb
- @Deprecated public void setHandleMethods(boolean b)
setPropertyHandling(PropertyHandling)
insteadb
- public void setPropertyHandling(PropertyHandling propertyHandling)
propertyHandling
- public void setUseFieldTypes(boolean b)
b
- public void addStopClass(Class<?> cl)
cl
- public void setStrictMode(boolean s)
s
- public void setSerializerConfig(SerializerConfig serializerConfig)
serializerConfig
- public void addAnnotationHelper(AnnotationHelper annotationHelper)
annotationHelper
- Copyright © 2007–2016 Querydsl. All rights reserved.