Class FunctionDefinitionBuilder

java.lang.Object
org.ofbiz.core.entity.model.FunctionDefinitionBuilder

public abstract class FunctionDefinitionBuilder extends Object
Base class for creating a function definition. The main purpose is to return different function definitions based on database type, for instance the substr function is different in each of our supported databases. You should provide an override of this class for your function definition, for example
  
     public class LowerFunctionDefinitionBuilder extends FunctionDefinitionBuilder  {

          public LowerFunctionDefinitionBuilder(String virtualColumn, String type, List<String> columns, @Nullable String argsList) {
              super(virtualColumn, type, columns, argsList);
          }

          public String getFunctionDefinition(DatabaseType databaseType) {
              String column = columns.get(0);
              return "lower(" + column +")";
          }
      }
  
  
  • Field Details

    • columns

      protected final List<String> columns
    • argsList

      protected final String argsList
  • Constructor Details

    • FunctionDefinitionBuilder

      public FunctionDefinitionBuilder(String virtualColumn, String type, List<String> columns, @Nullable String argsList)
      Parameters:
      virtualColumn - the name of any virtual column to be created, must be provided, but only used in MySql and SQLServer
      type - the model type of the virtual column, this should be the same as the function return type and is something like "long-varchar".
      columns - a list of columns that the function operates on, must contain at least one column.
      argsList - an optional comma separated string of arguments to be provided to the function.
  • Method Details

    • getVirtualColumn

      @Nullable public String getVirtualColumn(DatabaseType dbType)
      Returns:
      the name of the vitrtual column to create in the databse. Only those databases that do not support function based indexes need to create a column, so return null for supported databases.
    • getType

      public String getType()
    • getFunctionDefinition

      public abstract String getFunctionDefinition(DatabaseType databaseType)
    • supportsFunctionBasedIndices

      public boolean supportsFunctionBasedIndices(DatabaseType dbType)