public class GenericExporter
extends java.lang.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(java.nio.charset.Charset charset)
Create a GenericExporter instance using the context classloader and the given charset
|
GenericExporter(java.lang.ClassLoader classLoader)
Create a GenericExporter instance using the given classloader and default charset
|
GenericExporter(java.lang.ClassLoader classLoader,
java.nio.charset.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(java.lang.Class<?> cl)
Add a stop class to be used (default Object.class and Enum.class)
|
void |
export(java.lang.Class<?>... classes)
Export the given classes
|
void |
export(java.lang.Package... packages)
Export the given packages
|
void |
export(java.lang.String... packages)
Export the given packages
|
java.util.Set<java.io.File> |
getGeneratedFiles()
Return the set of generated files
|
void |
setCreateScalaSources(boolean createScalaSources)
Set whether Scala sources are generated
|
void |
setEmbeddableAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> embeddableAnnotation)
Set the embeddable annotation
|
void |
setEmbeddedAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> embeddedAnnotation)
Set the embedded annotation
|
void |
setEntityAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> entityAnnotation)
Set the entity annotation
|
void |
setGeneratedAnnotationClass(@Nullable java.lang.String generatedAnnotationClass)
Set the Generated annotation class.
|
void |
setHandleFields(boolean b)
Deprecated.
Use
setPropertyHandling(PropertyHandling) instead |
void |
setHandleMethods(boolean b)
Deprecated.
Use
setPropertyHandling(PropertyHandling) instead |
void |
setKeywords(java.util.Collection<java.lang.String> keywords)
Set the keywords to be used
|
void |
setNamePrefix(java.lang.String prefix)
Set the name prefix
|
void |
setNameSuffix(java.lang.String suffix)
Set the name suffix
|
void |
setPackageSuffix(java.lang.String suffix)
Set the package suffix
|
void |
setPropertyHandling(PropertyHandling propertyHandling)
Set the property handling mode
|
void |
setSerializerClass(java.lang.Class<? extends Serializer> serializerClass)
Set the serializer class to be used
|
void |
setSerializerConfig(SerializerConfig serializerConfig)
Set the serializer configuration to use
|
void |
setSkipAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> skipAnnotation)
Set the skip annotation
|
void |
setStrictMode(boolean s)
Set whether annotationless superclasses are handled or not (default: true)
|
void |
setSupertypeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> supertypeAnnotation)
Set the supertype annotation
|
void |
setTargetFolder(java.io.File targetFolder)
Set the target folder for generated sources
|
void |
setTypeMappingsClass(java.lang.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(java.lang.ClassLoader classLoader, java.nio.charset.Charset charset)
classLoader
- classloader to usecharset
- charset of target sourcespublic GenericExporter(java.lang.ClassLoader classLoader)
classLoader
- classloader to usepublic GenericExporter(java.nio.charset.Charset charset)
charset
- charset of target sourcespublic GenericExporter()
public void export(java.lang.Package... packages)
packages
- packages to be scannedpublic void export(java.lang.String... packages)
packages
- packages to be scannedpublic void export(java.lang.Class<?>... classes)
classes
- classes to be scannedpublic java.util.Set<java.io.File> getGeneratedFiles()
public void setEntityAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> entityAnnotation)
entityAnnotation
- entity annotationpublic void setSupertypeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> supertypeAnnotation)
supertypeAnnotation
- supertype annotationpublic void setEmbeddableAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> embeddableAnnotation)
embeddableAnnotation
- embeddable annotationpublic void setEmbeddedAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> embeddedAnnotation)
embeddedAnnotation
- embedded annotationpublic void setSkipAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> skipAnnotation)
skipAnnotation
- skip annotationpublic void setTargetFolder(java.io.File targetFolder)
targetFolder
- public void setSerializerClass(java.lang.Class<? extends Serializer> serializerClass)
serializerClass
- public void setTypeMappingsClass(java.lang.Class<? extends TypeMappings> typeMappingsClass)
typeMappingsClass
- public void setCreateScalaSources(boolean createScalaSources)
createScalaSources
- public void setKeywords(java.util.Collection<java.lang.String> keywords)
keywords
- public void setNamePrefix(java.lang.String prefix)
prefix
- public void setNameSuffix(java.lang.String suffix)
suffix
- public void setPackageSuffix(java.lang.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(java.lang.Class<?> cl)
cl
- public void setStrictMode(boolean s)
s
- public void setSerializerConfig(SerializerConfig serializerConfig)
serializerConfig
- public void addAnnotationHelper(AnnotationHelper annotationHelper)
annotationHelper
- public void setGeneratedAnnotationClass(@Nullable @Nullable java.lang.String generatedAnnotationClass)
@Generated
generatedAnnotationClass
- the fully qualified class name of the Single-Element Annotation (with String
element) to be used on
the generated sources, or null
(defaulting to javax.annotation.Generated
or
javax.annotation.processing.Generated
depending on the java version).Copyright © 2007–2021 Querydsl. All rights reserved.