/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Other licenses:
 * -----------------------------------------------------------------------------
 * Commercial licenses for this work are available. These replace the above
 * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
 * database integrations.
 *
 * For more information, please visit: http://www.jooq.org/licenses
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
package org.jooq.codegen;

import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.Locale;

import org.jooq.codegen.AbstractGenerator.Language;
import org.jooq.meta.AttributeDefinition;
import org.jooq.meta.ColumnDefinition;
import org.jooq.meta.Definition;
import org.jooq.meta.DomainDefinition;
import org.jooq.meta.EnumDefinition;
import org.jooq.meta.ParameterDefinition;
import org.jooq.meta.RoutineDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;

A strategy for naming various artefacts generated from Definition's
Author:Lukas Eder
/** * A strategy for naming various artefacts generated from {@link Definition}'s * * @author Lukas Eder */
public interface GeneratorStrategy { // ------------------------------------------------------------------------- // XXX: Configuration of the strategy // -------------------------------------------------------------------------
The target directory
/** * The target directory */
String getTargetDirectory();
Initialise the target directory
/** * Initialise the target directory */
void setTargetDirectory(String directory);
Returns:Get the target package for the current configuration
/** * @return Get the target package for the current configuration */
String getTargetPackage();
Initialise the target package name
/** * Initialise the target package name */
void setTargetPackage(String packageName);
Returns:Get the target locale for the current configuration
/** * @return Get the target locale for the current configuration */
Locale getTargetLocale();
Initialise the target locale
/** * Initialise the target locale */
void setTargetLocale(Locale targetLocale);
Returns:Get the target language for the current configuration
/** * @return Get the target language for the current configuration */
Language getTargetLanguage();
Initialise the target language
/** * Initialise the target language */
void setTargetLanguage(Language targetLanguage);
Whether fields are instance fields (as opposed to static fields)
/** * Whether fields are instance fields (as opposed to static fields) */
void setInstanceFields(boolean instanceFields);
Whether fields are instance fields (as opposed to static fields)
/** * Whether fields are instance fields (as opposed to static fields) */
boolean getInstanceFields();
Whether getters and setters should be generated JavaBeans style (or jOOQ style).
/** * Whether getters and setters should be generated JavaBeans style (or jOOQ style). */
void setJavaBeansGettersAndSetters(boolean javaBeansGettersAndSetters);
Whether getters and setters should be generated JavaBeans style (or jOOQ style).
/** * Whether getters and setters should be generated JavaBeans style (or jOOQ style). */
boolean getJavaBeansGettersAndSetters(); // ------------------------------------------------------------------------- // XXX: The SPI // -------------------------------------------------------------------------
This is applied to definitions that can result in reference static and instance members. For instance, the reference instance of a TableDefinition is a java identifier
Returns:The Java identifier representing this object, e.g. [my_table]
/** * This is applied to definitions that can result in reference static and * instance members. For instance, the reference instance of a * {@link TableDefinition} is a java identifier * * @return The Java identifier representing this object, e.g. [my_table] */
String getJavaIdentifier(Definition definition);
See Also:
  • getJavaIdentifier(Definition)
/** * @see #getJavaIdentifier(Definition) */
List<String> getJavaIdentifiers(Collection<? extends Definition> definitions);
See Also:
  • getJavaIdentifier(Definition)
/** * @see #getJavaIdentifier(Definition) */
List<String> getJavaIdentifiers(Definition... definitions);
This is applied to definitions that can result in reference static and instance members. For instance, the reference instance of a TableDefinition is a java identifier
Returns:The Java identifier representing this object, e.g. [my_table]
/** * This is applied to definitions that can result in reference static and * instance members. For instance, the reference instance of a * {@link TableDefinition} is a java identifier * * @return The Java identifier representing this object, e.g. [my_table] */
String getFullJavaIdentifier(Definition definition);
See Also:
  • getFullJavaIdentifier(Definition)
/** * @see #getFullJavaIdentifier(Definition) */
List<String> getFullJavaIdentifiers(Collection<? extends Definition> definitions);
See Also:
  • getFullJavaIdentifier(Definition)
/** * @see #getFullJavaIdentifier(Definition) */
List<String> getFullJavaIdentifiers(Definition... definitions);
This is applied to definitions that can result in setters of a container. For example, the definition could be a ColumnDefinition, the container a TableDefinition. Then this would apply to records and POJOs. Also, the definition could be an AttributeDefinition and the container a UDTDefinition

This is the same as calling getJavaSetterName(definition, Mode.DEFAULT)

Returns:The Java setter method name representing this object, e.g. [setMyTable]
/** * This is applied to definitions that can result in setters of a container. * For example, the definition could be a {@link ColumnDefinition}, the * container a {@link TableDefinition}. Then this would apply to records and * POJOs. Also, the definition could be an {@link AttributeDefinition} and * the container a {@link UDTDefinition} * <p> * This is the same as calling * <code>getJavaSetterName(definition, Mode.DEFAULT)</code> * * @return The Java setter method name representing this object, e.g. * [setMyTable] */
String getJavaSetterName(Definition definition);
This is applied to definitions that can result in setters of a container. For example, the definition could be a ColumnDefinition, the container a TableDefinition. Then this would apply to records and POJOs. Also, the definition could be an AttributeDefinition and the container a UDTDefinition
Returns:The Java setter method name representing this object, e.g. [setMyTable]
/** * This is applied to definitions that can result in setters of a container. * For example, the definition could be a {@link ColumnDefinition}, the * container a {@link TableDefinition}. Then this would apply to records and * POJOs. Also, the definition could be an {@link AttributeDefinition} and * the container a {@link UDTDefinition} * * @return The Java setter method name representing this object, e.g. * [setMyTable] */
String getJavaSetterName(Definition definition, Mode mode);
This is applied to definitions that can result in getters of a container. For example, the definition could be a ColumnDefinition, the container a TableDefinition. Then this would apply to records and POJOs. Also, the definition could be an AttributeDefinition and the container a UDTDefinition

This is the same as calling getJavaGetterName(definition, Mode.DEFAULT)

Returns:The Java getter method name representing this object, e.g. [getMyTable]
/** * This is applied to definitions that can result in getters of a container. * For example, the definition could be a {@link ColumnDefinition}, the * container a {@link TableDefinition}. Then this would apply to records and * POJOs. Also, the definition could be an {@link AttributeDefinition} and * the container a {@link UDTDefinition} * <p> * This is the same as calling * <code>getJavaGetterName(definition, Mode.DEFAULT)</code> * * @return The Java getter method name representing this object, e.g. * [getMyTable] */
String getJavaGetterName(Definition definition);
This is applied to definitions that can result in getters of a container. For example, the definition could be a ColumnDefinition, the container a TableDefinition. Then this would apply to records and POJOs. Also, the definition could be an AttributeDefinition and the container a UDTDefinition
Returns:The Java getter method name representing this object, e.g. [getMyTable]
/** * This is applied to definitions that can result in getters of a container. * For example, the definition could be a {@link ColumnDefinition}, the * container a {@link TableDefinition}. Then this would apply to records and * POJOs. Also, the definition could be an {@link AttributeDefinition} and * the container a {@link UDTDefinition} * * @return The Java getter method name representing this object, e.g. * [getMyTable] */
String getJavaGetterName(Definition definition, Mode mode);
This is applied to definitions that can result in methods. For example, the definition could be a RoutineDefinition

This is the same as calling getJavaMethodName(definition, Mode.DEFAULT)

Returns:The Java method name representing this object, e.g. [myFunction]
/** * This is applied to definitions that can result in methods. For example, * the definition could be a {@link RoutineDefinition} * <p> * This is the same as calling * <code>getJavaMethodName(definition, Mode.DEFAULT)</code> * * @return The Java method name representing this object, e.g. [myFunction] */
String getJavaMethodName(Definition definition);
This is applied to definitions that can result in methods. For example, the definition could be a RoutineDefinition
Returns:The Java method name representing this object, e.g. [myFunction]
/** * This is applied to definitions that can result in methods. For example, * the definition could be a {@link RoutineDefinition} * * @return The Java method name representing this object, e.g. [myFunction] */
String getJavaMethodName(Definition definition, Mode mode);
Returns:The super class name of the global references class for a given definition type, e.g. [com.example.AbstractPojo]. If this returns null or an empty string, then no super class is extended.
/** * @return The super class name of the global references class for a given * definition type, e.g. [com.example.AbstractPojo]. If this returns * <code>null</code> or an empty string, then no super class is * extended. */
String getGlobalReferencesJavaClassExtends(Definition container, Class<? extends Definition> objectType);
This is the same as calling getJavaClassExtends(definition, Mode.DEFAULT)
Returns:The super class name of the Java class representing this object, e.g. [com.example.AbstractPojo]. If this returns null or an empty string, then no super class is extended.
/** * This is the same as calling * <code>getJavaClassExtends(definition, Mode.DEFAULT)</code> * * @return The super class name of the Java class representing this object, * e.g. [com.example.AbstractPojo]. If this returns * <code>null</code> or an empty string, then no super class is * extended. */
String getJavaClassExtends(Definition definition);
Returns:The super class name of the Java class representing this object, e.g. [com.example.AbstractPojo]. If this returns null or an empty string, then no super class is extended.
/** * @return The super class name of the Java class representing this object, * e.g. [com.example.AbstractPojo]. If this returns * <code>null</code> or an empty string, then no super class is * extended. */
String getJavaClassExtends(Definition definition, Mode mode);
Returns:The implemented interface names of the global references class for a given definition type, e.g. [com.example.Pojo]. If this returns null or an empty list, then no interfaces are implemented.
/** * @return The implemented interface names of the global references class * for a given definition type, e.g. [com.example.Pojo]. If this * returns <code>null</code> or an empty list, then no interfaces * are implemented. */
List<String> getGlobalReferencesJavaClassImplements(Definition container, Class<? extends Definition> objectType);
This is the same as calling getJavaClassImplements(definition, Mode.DEFAULT)
Returns:The implemented interface names of the Java class name representing this object, e.g. [com.example.Pojo] If this returns null or an empty list, then no interfaces are implemented.
/** * This is the same as calling * <code>getJavaClassImplements(definition, Mode.DEFAULT)</code> * * @return The implemented interface names of the Java class name * representing this object, e.g. [com.example.Pojo] If this returns * <code>null</code> or an empty list, then no interfaces are * implemented. */
List<String> getJavaClassImplements(Definition definition);
Returns:The implemented interface names of the Java class name representing this object, e.g. [com.example.Pojo]. If this returns null or an empty list, then no interfaces are implemented.
/** * @return The implemented interface names of the Java class name * representing this object, e.g. [com.example.Pojo]. If this * returns <code>null</code> or an empty list, then no interfaces * are implemented. */
List<String> getJavaClassImplements(Definition definition, Mode mode);
Returns:The Java class name of the global references class for a given definition type, e.g. [MyTableSuffix]
/** * @return The Java class name of the global references class for a given * definition type, e.g. [MyTableSuffix] */
String getGlobalReferencesJavaClassName(Definition container, Class<? extends Definition> objectType);
This is the same as calling getJavaClassName(definition, Mode.DEFAULT)
Returns:The Java class name representing this object, e.g. [MyTable]
/** * This is the same as calling * <code>getJavaClassName(definition, Mode.DEFAULT)</code> * * @return The Java class name representing this object, e.g. [MyTable] */
String getJavaClassName(Definition definition);
Returns:The Java class name representing this object, e.g. [MyTableSuffix]
/** * @return The Java class name representing this object, e.g. * [MyTableSuffix] */
String getJavaClassName(Definition definition, Mode mode);
Returns:The Java package name of the global references class for a given definition type, e.g. [org.jooq.generated]
/** * @return The Java package name of the global references class for a given * definition type, e.g. [org.jooq.generated] */
String getGlobalReferencesJavaPackageName(Definition container, Class<? extends Definition> objectType);
This is the same as calling getJavaPackageName(definition, Mode.DEFAULT)
Returns:The Java package name of this object, e.g. [org.jooq.generated]
/** * This is the same as calling * <code>getJavaPackageName(definition, Mode.DEFAULT)</code> * * @return The Java package name of this object, e.g. [org.jooq.generated] */
String getJavaPackageName(Definition definition);
Returns:The Java package name of this object, e.g. [org.jooq.generated]
/** * @return The Java package name of this object, e.g. [org.jooq.generated] */
String getJavaPackageName(Definition definition, Mode mode);
The "java member name" is applied where a definition is used as a member (for POJOs) or as a method argument (for setters). Example definitions are This is the same as calling getJavaMemberName(definition, Mode.DEFAULT)
Returns:The Java class name representing this object, starting with a lower case character, e.g. [myTable]
/** * The "java member name" is applied where a definition is used as a member * (for POJOs) or as a method argument (for setters). Example definitions * are * <ul> * <li>{@link ColumnDefinition}</li> * <li>{@link ParameterDefinition}</li> * <li>{@link AttributeDefinition}</li> * </ul> * This is the same as calling * <code>getJavaMemberName(definition, Mode.DEFAULT)</code> * * @return The Java class name representing this object, starting with a * lower case character, e.g. [myTable] */
String getJavaMemberName(Definition definition);
The "java member name" is applied where a definition is used as a member (for POJOs) or as a method argument (for setters). Example definitions are
Returns:The Java class name representing this object, starting with a lower case character, e.g. [myTableSuffix]
/** * The "java member name" is applied where a definition is used as a member * (for POJOs) or as a method argument (for setters). Example definitions * are * <ul> * <li>{@link ColumnDefinition}</li> * <li>{@link ParameterDefinition}</li> * <li>{@link AttributeDefinition}</li> * </ul> * * @return The Java class name representing this object, starting with a * lower case character, e.g. [myTableSuffix] */
String getJavaMemberName(Definition definition, Mode mode);
Returns:The full Java class name of the global references class for a given definition type, e.g. [org.jooq.generated.MyTable]
/** * @return The full Java class name of the global references class for a * given definition type, e.g. [org.jooq.generated.MyTable] */
String getGlobalReferencesFullJavaClassName(Definition container, Class<? extends Definition> objectType);
Returns:The full Java class name representing this object, e.g. [org.jooq.generated.MyTable]
/** * @return The full Java class name representing this object, e.g. * [org.jooq.generated.MyTable] */
String getFullJavaClassName(Definition definition);
This is the same as calling getFullJavaClassName(definition, Mode.DEFAULT)
Returns:The full Java class name representing this object, e.g. [org.jooq.generated.MyTable][suffix]
/** * This is the same as calling * <code>getFullJavaClassName(definition, Mode.DEFAULT)</code> * * @return The full Java class name representing this object, e.g. * [org.jooq.generated.MyTable][suffix] */
String getFullJavaClassName(Definition definition, Mode mode);
Returns:The Java class file name of the global references class for a given definition type, e.g. [MyTable.java]
/** * @return The Java class file name of the global references class for a * given definition type, e.g. [MyTable.java] */
String getGlobalReferencesFileName(Definition container, Class<? extends Definition> objectType);
Returns:The Java class file name representing this object, e.g. [MyTable.java]
/** * @return The Java class file name representing this object, e.g. * [MyTable.java] */
String getFileName(Definition definition);
Returns:The Java class file name representing this object, e.g. [MyTableSuffix.java]
/** * @return The Java class file name representing this object, e.g. * [MyTableSuffix.java] */
String getFileName(Definition definition, Mode mode);
Returns:The directory containing all Java objects, e.g. [C:\org\jooq\generated]
/** * @return The directory containing all Java objects, e.g. * [C:\org\jooq\generated] */
File getFileRoot();
Returns:The Java class file name of the global references class for a given definition type, e.g. [C:\org\jooq\generated\MyTable.java]
/** * @return The Java class file name of the global references class for a * given definition type, e.g. [C:\org\jooq\generated\MyTable.java] */
File getGlobalReferencesFile(Definition container, Class<? extends Definition> objectType);
Returns:The Java class file name representing this object, e.g. [C:\org\jooq\generated\MyTable.java]
/** * @return The Java class file name representing this object, e.g. * [C:\org\jooq\generated\MyTable.java] */
File getFile(Definition definition);
Returns:The Java class file name representing this object, e.g. [C:\org\jooq\generated\MyTableSuffix.java]
/** * @return The Java class file name representing this object, e.g. * [C:\org\jooq\generated\MyTableSuffix.java] */
File getFile(Definition definition, Mode mode);
Returns:The Java class file name representing this object, e.g. [C:\org\jooq\generated\fileName]
/** * @return The Java class file name representing this object, e.g. * [C:\org\jooq\generated\fileName] */
File getFile(String fileName);
Returns:The Java class file header of the global references class for a given definition type, e.g.
This file is generated by jOOQ.
/** * @return The Java class file header of the global references class for a * given definition type, e.g. <code><pre> * This file is generated by jOOQ. * </pre></code> */
String getGlobalReferencesFileHeader(Definition container, Class<? extends Definition> objectType);
Returns:The Java class file header, e.g.
This file is generated by jOOQ.
/** * @return The Java class file header, e.g. <code><pre> * This file is generated by jOOQ. * </pre></code> */
String getFileHeader(Definition definition);
Returns:The Java class file header, e.g.
This file is generated by jOOQ.
/** * @return The Java class file header, e.g. <code><pre> * This file is generated by jOOQ. * </pre></code> */
String getFileHeader(Definition definition, Mode mode);
Returns:The overload suffix to be applied when generating overloaded routine artefacts, e.g. "_OverloadIndex_" + overloadIndex
/** * @return The overload suffix to be applied when generating overloaded * routine artefacts, e.g. * <code>"_OverloadIndex_" + overloadIndex</code> */
String getOverloadSuffix(Definition definition, Mode mode, String overloadIndex);
The "mode" by which an artefact should be named
/** * The "mode" by which an artefact should be named */
enum Mode {
The default mode. This is used when any Definition's meta type is being rendered.
/** * The default mode. This is used when any {@link Definition}'s meta * type is being rendered. */
DEFAULT,
The record mode. This is used when a TableDefinition or a UDTDefinition's record class is being rendered.
/** * The record mode. This is used when a {@link TableDefinition} or a * {@link UDTDefinition}'s record class is being rendered. */
RECORD,
The pojo mode. This is used when a TableDefinition's pojo class is being rendered
/** * The pojo mode. This is used when a {@link TableDefinition}'s pojo * class is being rendered */
POJO,
the interface mode. This is used when a TableDefinition's interface is being rendered
/** * the interface mode. This is used when a {@link TableDefinition}'s * interface is being rendered */
INTERFACE,
The dao mode. This is used when a TableDefinition's dao class is being rendered
/** * The dao mode. This is used when a {@link TableDefinition}'s dao class * is being rendered */
DAO,
The enum mode. This is used when a EnumDefinition's class is being rendered
/** * The enum mode. This is used when a {@link EnumDefinition}'s class is * being rendered */
ENUM,
The domain mode. This is used when a DomainDefinition's class is being rendered
/** * The domain mode. This is used when a {@link DomainDefinition}'s class * is being rendered */
DOMAIN } }