com.mysema.query.codegen
Class GenericExporter

java.lang.Object
  extended by com.mysema.query.codegen.GenericExporter

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());
 

Author:
tiwe

Constructor Summary
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
 
Method Summary
 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
 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)
          Set whether fields are handled (default true)
 void setHandleMethods(boolean b)
          Set whether fields are handled (default true)
 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 setSerializerClass(Class<? extends Serializer> serializerClass)
          Set the serializer class to be used
 void setSkipAnnotation(Class<? extends Annotation> skipAnnotation)
          Set the skip annotation
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericExporter

public GenericExporter(ClassLoader classLoader,
                       Charset charset)
Create a GenericExporter instance using the given classloader and charset for serializing source files

Parameters:
classLoader -
charset -

GenericExporter

public GenericExporter(ClassLoader classLoader)
Create a GenericExporter instance using the given classloader and default charset

Parameters:
classLoader -

GenericExporter

public GenericExporter(Charset charset)
Create a GenericExporter instance using the context classloader and the given charset

Parameters:
charset -

GenericExporter

public GenericExporter()
Create a GenericExporter instance using the context classloader and default charset

Method Detail

export

public void export(Package... packages)
Export the given packages

Parameters:
packages -

export

public void export(String... packages)
Export the given packages

Parameters:
packages -

export

public void export(Class<?>... classes)
Export the given classes

Parameters:
classes -

setEntityAnnotation

public void setEntityAnnotation(Class<? extends Annotation> entityAnnotation)
Set the entity annotation

Parameters:
entityAnnotation -

setSupertypeAnnotation

public void setSupertypeAnnotation(Class<? extends Annotation> supertypeAnnotation)
Set the supertype annotation

Parameters:
supertypeAnnotation -

setEmbeddableAnnotation

public void setEmbeddableAnnotation(Class<? extends Annotation> embeddableAnnotation)
Set the embeddable annotation

Parameters:
embeddableAnnotation -

setEmbeddedAnnotation

public void setEmbeddedAnnotation(Class<? extends Annotation> embeddedAnnotation)
Set the embedded annotation

Parameters:
embeddedAnnotation -

setSkipAnnotation

public void setSkipAnnotation(Class<? extends Annotation> skipAnnotation)
Set the skip annotation

Parameters:
skipAnnotation -

setTargetFolder

public void setTargetFolder(File targetFolder)
Set the target folder for generated sources

Parameters:
targetFolder -

setSerializerClass

public void setSerializerClass(Class<? extends Serializer> serializerClass)
Set the serializer class to be used

Parameters:
serializerClass -

setTypeMappingsClass

public void setTypeMappingsClass(Class<? extends TypeMappings> typeMappingsClass)
Set the typemappings class to be used

Parameters:
typeMappingsClass -

setCreateScalaSources

public void setCreateScalaSources(boolean createScalaSources)
Set whether Scala sources are generated

Parameters:
createScalaSources -

setKeywords

public void setKeywords(Collection<String> keywords)
Set the keywords to be used

Parameters:
keywords -

setNamePrefix

public void setNamePrefix(String prefix)
Set the name prefix

Parameters:
prefix -

setNameSuffix

public void setNameSuffix(String suffix)
Set the name suffix

Parameters:
suffix -

setPackageSuffix

public void setPackageSuffix(String suffix)
Set the package suffix

Parameters:
suffix -

setHandleFields

public void setHandleFields(boolean b)
Set whether fields are handled (default true)

Parameters:
b -

setHandleMethods

public void setHandleMethods(boolean b)
Set whether fields are handled (default true)

Parameters:
b -

addStopClass

public void addStopClass(Class<?> cl)
Add a stop class to be used (default Object.class and Enum.class)

Parameters:
cl -


Copyright © 2007-2012 Mysema Ltd. All Rights Reserved.