Example usage for org.springframework.util Assert doesNotContain

List of usage examples for org.springframework.util Assert doesNotContain

Introduction

In this page you can find the example usage for org.springframework.util Assert doesNotContain.

Prototype

public static void doesNotContain(@Nullable String textToSearch, String substring,
        Supplier<String> messageSupplier) 

Source Link

Document

Assert that the given text does not contain the given substring.

Usage

From source file:org.sharetask.utility.log.ErrorInterceptor.java

/**
 * Set the template used for method exception log messages.
 * This template can contain any of the following placeholders:
 * <ul>// w  w w . j  a  v a 2 s . co m
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[exception]}</li>
 * </ul>
 */
@Override
public void setExceptionMessage(final String exceptionMessage) {
    Assert.hasText(exceptionMessage, "'exceptionMessage' must not be empty");
    Assert.doesNotContain(exceptionMessage, PLACEHOLDER_RETURN_VALUE,
            "exceptionMessage cannot contain placeholder [" + PLACEHOLDER_RETURN_VALUE + "]");
    Assert.doesNotContain(exceptionMessage, PLACEHOLDER_INVOCATION_TIME,
            "exceptionMessage cannot contain placeholder [" + PLACEHOLDER_INVOCATION_TIME + "]");
    this.exceptionMessage = exceptionMessage;
}

From source file:org.sharetask.utility.log.PerformanceInterceptor.java

/**
 * Set the template used for method exit log messages.
 * This template can contain any of the following placeholders:
 * <ul>/*from w  w w. ja  v a 2s. c om*/
 * <li>{@code $[targetClassName]}</li>
 * <li>{@code $[targetClassShortName]}</li>
 * <li>{@code $[argumentTypes]}</li>
 * <li>{@code $[arguments]}</li>
 * <li>{@code $[returnValue]}</li>
 * <li>{@code $[invocationTime]}</li>
 * </ul>
 */
@Override
public void setExitMessage(final String exitMessage) {
    Assert.hasText(exitMessage, "'exitMessage' must not be empty");
    checkForInvalidPlaceholders(exitMessage);
    Assert.doesNotContain(exitMessage, PLACEHOLDER_EXCEPTION,
            "exitMessage cannot contain placeholder [" + PLACEHOLDER_EXCEPTION + "]");
    this.exitMessage = exitMessage;
}

From source file:net.kamhon.ieagle.dao.Jpa2Dao.java

@SuppressWarnings("unchecked")
public void findForDatagrid(DatagridModel<T> datagridModel, String alias, String queryString,
        String countQueryString, Object... objectArray) {
    boolean hasCountQueryString = StringUtils.isNotBlank(countQueryString);
    String countQuery = "";

    queryString = convertJpaPositionParams(queryString);
    Assert.isTrue(StringUtils.isNotBlank(alias), "The alias can not be BLANK!!");
    Assert.isTrue(StringUtils.isNotBlank(queryString), "The queryString can not be BLANK!!");

    if (CollectionUtil.isNotEmpty(datagridModel.getFilters())) {
        Assert.doesNotContain(queryString, BasicDao.FILTER_PARAMS, "The " + BasicDao.FILTER_PARAMS
                + " is not found in Query [" + queryString + "] if FILTERS is not EMPTY!!");
    }// w ww  .j a  v a 2  s . c  o  m
    /*************************
     * END VALIDATION
     ************************/
    String finalQuery = queryString.trim();
    List<Object> params = new ArrayList<Object>();
    if (objectArray != null) {
        if (objectArray.length == 1 && objectArray[0] instanceof List)
            params = (List<Object>) objectArray[0];
        else
            params = Arrays.asList(objectArray);
    }

    if (CollectionUtil.isNotEmpty(datagridModel.getFilters())) {
        for (Filter filter : datagridModel.getFilters()) {
            if (filter != null)
                throw new DataException("The Filter features still not implemented yet");
        }
    }

    List<Object> countParams = new ArrayList<Object>(params);
    if (hasCountQueryString)
        countQuery = countQueryString;
    else {
        countQuery = "SELECT COUNT(" + alias + ") ";

        if (finalQuery.toUpperCase().startsWith("SELECT")) {
            int ind = finalQuery.toUpperCase().indexOf("FROM");
            countQuery += finalQuery.substring(ind);
        } else {
            countQuery += finalQuery;
        }
    }

    if (!datagridModel.isDisableSort() && CollectionUtil.isNotEmpty(datagridModel.getSorters())) {
        if (StringUtils.contains(finalQuery.toUpperCase(), "ORDER BY")) {
            finalQuery += ", ";
        } else {
            finalQuery += " ORDER BY ";
        }

        for (Iterator<Sorter> iter = datagridModel.getSorters().iterator(); iter.hasNext();) {
            Sorter sorter = iter.next();

            if (StringUtils.isNotBlank(datagridModel.getExtraMapping(sorter.getColumn())))
                finalQuery += datagridModel.getExtraMapping(sorter.getColumn()) + " " + sorter.getDirection();
            else
                finalQuery += alias + "." + sorter.getColumn() + " " + sorter.getDirection();
            if (iter.hasNext()) {
                finalQuery += ", ";
            }
        }
    }

    // log.debug("countParams = " + countParams);
    // log.debug("countQuery = " + countQuery);

    // log.debug("params = " + params);
    // log.debug("finalQuery = " + finalQuery);

    List<T> result = (List<T>) findBlock(finalQuery, datagridModel.getRecordOffset(),
            datagridModel.getPageSize(), params.toArray());
    datagridModel.setRecords(result);

    Long count = (Long) this.findUnique(countQuery, countParams.toArray());
    datagridModel.setTotalRecords(count);
}

From source file:net.kamhon.ieagle.dao.JdbcDao.java

public <T> void queryForDatagrid(DatagridModel<T> datagridModel, String sql, RowMapper<T> rowMapper,
        Object[] params) {/*www. j a  v a 2s .c  o m*/
    Assert.isTrue(StringUtils.isNotBlank(sql), "The sql can not be BLANK!!");

    if (CollectionUtil.isNotEmpty(datagridModel.getFilters())) {
        Assert.doesNotContain(sql, BasicDao.FILTER_PARAMS, "The " + BasicDao.FILTER_PARAMS
                + " is not found in Query [" + sql + "] if FILTERS is not EMPTY!!");
    }

    Assert.notNull(getNativeDatabaseObject(), "The pagination Datagrid is not supported for your Database!!");
    /*************************
     * END VALIDATION
     ************************/

    // to re-set the sorter.sqlColumn()
    datagridModel.processBeforeQuery();

    String finalQuery = sql;
    List<Object> finalParams = params != null ? Arrays.asList(params) : new ArrayList<Object>();

    if (CollectionUtil.isNotEmpty(datagridModel.getFilters())) {
        for (Filter filter : datagridModel.getFilters()) {
            if (filter != null)
                throw new DataException("The Filter features still not implemented yet");
        }
    }
    List<Object> countParams = new ArrayList<Object>(finalParams);
    String countQuery = "SELECT COUNT(*) FROM (" + finalQuery + ") t ";

    if (!datagridModel.isDisableSort() && CollectionUtil.isNotEmpty(datagridModel.getSorters())) {
        if (StringUtils.contains(finalQuery.toUpperCase(), "ORDER BY")) {
            finalQuery += ", ";
        } else {
            finalQuery += " ORDER BY ";
        }

        for (Iterator<Sorter> iter = datagridModel.getSorters().iterator(); iter.hasNext();) {
            Sorter sorter = iter.next();

            // here different with HibernateDao
            finalQuery += sorter.getSqlColumn() + " " + sorter.getDirection();
            if (iter.hasNext()) {
                finalQuery += ", ";
            }
        }
    }

    finalQuery = getNativeDatabaseObject().convertToPaginationSql(finalQuery, datagridModel.getRecordOffset(),
            datagridModel.getPageSize());

    /*log.debug("countParams = " + countParams);
    log.debug("countQuery = " + countQuery);
            
    log.debug("params = " + finalParams);
    log.debug("finalQuery = " + finalQuery);*/

    long count = 0;
    if (CollectionUtil.isEmpty(countParams)) {
        count = queryForLong(countQuery);
    } else {
        count = queryForLong(countQuery, countParams.toArray());
    }

    List<T> result = null;
    if (CollectionUtil.isEmpty(finalParams)) {
        result = (List<T>) query(finalQuery, rowMapper);
    } else {
        result = (List<T>) query(finalQuery, rowMapper, finalParams.toArray());
    }
    datagridModel.setRecords(result);
    datagridModel.setTotalRecords(count);
}

From source file:net.kamhon.ieagle.dao.JpaDao.java

@Override
public void findForDatagrid(DatagridModel<T> datagridModel, String alias, String queryString,
        Object... objectArray) {//from w w  w  .j ava2  s  .  c o m
    queryString = convertJpaPositionParams(queryString);
    Assert.isTrue(StringUtils.isNotBlank(alias), "The alias can not be BLANK!!");
    Assert.isTrue(StringUtils.isNotBlank(queryString), "The queryString can not be BLANK!!");

    if (CollectionUtil.isNotEmpty(datagridModel.getFilters())) {
        Assert.doesNotContain(queryString, BasicDao.FILTER_PARAMS, "The " + BasicDao.FILTER_PARAMS
                + " is not found in Query [" + queryString + "] if FILTERS is not EMPTY!!");
    }
    /*************************
     * END VALIDATION
     ************************/
    String finalQuery = queryString.trim();
    List<Object> params = new ArrayList<Object>();
    if (objectArray != null) {
        if (objectArray.length == 1 && objectArray[0] instanceof List)
            params = (List<Object>) objectArray[0];
        else
            params = Arrays.asList(objectArray);
    }

    if (CollectionUtil.isNotEmpty(datagridModel.getFilters())) {
        for (Filter filter : datagridModel.getFilters()) {
            if (filter != null)
                throw new DataException("The Filter features still not implemented yet");
        }
    }

    List<Object> countParams = new ArrayList<Object>(params);
    String countQuery = "SELECT COUNT(" + alias + ") ";

    if (finalQuery.toUpperCase().startsWith("SELECT")) {
        int ind = finalQuery.toUpperCase().indexOf("FROM");
        countQuery += finalQuery.substring(ind);
    } else {
        countQuery += finalQuery;
    }

    if (!datagridModel.isDisableSort() && CollectionUtil.isNotEmpty(datagridModel.getSorters())) {
        if (StringUtils.contains(finalQuery.toUpperCase(), "ORDER BY")) {
            finalQuery += ", ";
        } else {
            finalQuery += " ORDER BY ";
        }

        for (Iterator<Sorter> iter = datagridModel.getSorters().iterator(); iter.hasNext();) {
            Sorter sorter = iter.next();
            finalQuery += alias + "." + sorter.getColumn() + " " + sorter.getDirection();
            if (iter.hasNext()) {
                finalQuery += ", ";
            }
        }
    }

    // log.debug("countParams = " + countParams);
    // log.debug("countQuery = " + countQuery);

    // log.debug("params = " + params);
    // log.debug("finalQuery = " + finalQuery);

    List<T> result = (List<T>) findBlock(finalQuery, datagridModel.getRecordOffset(),
            datagridModel.getPageSize(), params.toArray());
    datagridModel.setRecords(result);

    Long count = (Long) this.findUnique(countQuery, countParams.toArray());
    datagridModel.setTotalRecords(count);
}

From source file:ch.ralscha.extdirectspring.controller.ApiControllerWithDocumentationTest.java

private void doRequestWithoutDocs(String url) throws Exception {
    ApiRequestParams params = ApiRequestParams.builder().apiNs("Ext.ns").actionNs("actionns").group("doc")
            .configuration(configurationService.getConfiguration()).build();
    MockHttpServletRequestBuilder request = get(url).accept(MediaType.ALL).characterEncoding("UTF-8");
    request.param("apiNs", params.getApiNs());
    request.param("actionNs", params.getActionNs());
    request.param("group", params.getGroup());

    MvcResult result = mockMvc.perform(request).andExpect(status().isOk())
            .andExpect(content().contentType("application/javascript")).andReturn();

    ApiControllerTest.compare(result, ApiControllerTest.groupApisWithDoc("actionns"), params);
    Assert.doesNotContain("/**", result.getResponse().getContentAsString(),
            "generation of api.js should not contain method documentation");
}

From source file:net.kamhon.ieagle.dao.HibernateDao.java

@SuppressWarnings("unchecked")
public void findForDatagrid(DatagridModel<T> datagridModel, String alias, String queryString,
        Object... objectArray) {/* w w  w .j  ava2s. c o m*/
    Assert.isTrue(StringUtils.isNotBlank(alias), "The alias can not be BLANK!!");
    Assert.isTrue(StringUtils.isNotBlank(queryString), "The queryString can not be BLANK!!");

    if (CollectionUtil.isNotEmpty(datagridModel.getFilters())) {
        Assert.doesNotContain(queryString, BasicDao.FILTER_PARAMS, "The " + BasicDao.FILTER_PARAMS
                + " is not found in Query [" + queryString + "] if FILTERS is not EMPTY!!");
    }
    /*************************
     * END VALIDATION
     ************************/
    String finalQuery = queryString.trim();
    List<Object> params = new ArrayList<Object>();
    if (objectArray != null) {
        if (objectArray.length == 1 && objectArray[0] instanceof List)
            params = (List<Object>) objectArray[0];
        else
            params = Arrays.asList(objectArray);
    }

    if (CollectionUtil.isNotEmpty(datagridModel.getFilters())) {
        for (Filter filter : datagridModel.getFilters()) {
            if (filter != null)
                throw new DataException("The Filter features still not implemented yet");
        }
    }

    List<Object> countParams = new ArrayList<Object>(params);
    String countQuery = "SELECT COUNT(" + alias + ") ";

    if (finalQuery.toUpperCase().startsWith("SELECT")) {
        int ind = finalQuery.toUpperCase().indexOf("FROM");
        countQuery += finalQuery.substring(ind);
    } else {
        countQuery += finalQuery;
    }

    if (!datagridModel.isDisableSort() && CollectionUtil.isNotEmpty(datagridModel.getSorters())) {
        if (StringUtils.contains(finalQuery.toUpperCase(), "ORDER BY")) {
            finalQuery += ", ";
        } else {
            finalQuery += " ORDER BY ";
        }

        for (Iterator<Sorter> iter = datagridModel.getSorters().iterator(); iter.hasNext();) {
            Sorter sorter = iter.next();
            finalQuery += alias + "." + sorter.getColumn() + " " + sorter.getDirection();
            if (iter.hasNext()) {
                finalQuery += ", ";
            }
        }
    }

    // log.debug("countParams = " + countParams);
    // log.debug("countQuery = " + countQuery);

    // log.debug("params = " + params);
    // log.debug("finalQuery = " + finalQuery);

    List<T> result = (List<T>) findBlock(finalQuery, datagridModel.getRecordOffset(),
            datagridModel.getPageSize(), params.toArray());
    datagridModel.setRecords(result);

    Long count = (Long) this.findUnique(countQuery, countParams.toArray());
    datagridModel.setTotalRecords(count);
}

From source file:org.finra.dm.service.helper.Hive13DdlGenerator.java

/**
 * Generates and append to the string builder the create table Hive 13 DDL as per specified parameters.
 *///w  ww . j  a va2s .com
private String generateCreateTableDdlHelper(BusinessObjectFormatEntity businessObjectFormatEntity,
        CustomDdlEntity customDdlEntity, Boolean isPartitioned, String tableName,
        Boolean includeDropTableStatement, Boolean includeIfNotExistsOption, Boolean allowMissingData,
        List<List<String>> partitionFilters, Integer businessObjectFormatVersion,
        Integer businessObjectDataVersion, StorageEntity storageEntity, String s3BucketName) {
    // TODO: We might want to consider using a template engine such as Velocity to generate this DDL so we don't wind up just doing string manipulation.

    StringBuilder sb = new StringBuilder();

    // For custom DDL, we would need to substitute the custom DDL tokens with their relative values.
    HashMap<String, String> replacements = new HashMap<>();

    // Validate that partition values passed in the list of partition filters do not contain '/' character.
    if (isPartitioned && !CollectionUtils.isEmpty(partitionFilters)) {
        // Validate that partition values do not contain '/' characters.
        for (List<String> partitionFilter : partitionFilters) {
            for (String partitionValue : partitionFilter) {
                Assert.doesNotContain(partitionValue, "/", String
                        .format("Partition value \"%s\" can not contain a '/' character.", partitionValue));
            }
        }
    }

    // Get business object format model object to directly access schema columns and partitions.
    BusinessObjectFormat businessObjectFormat = businessObjectFormatHelper
            .createBusinessObjectFormatFromEntity(businessObjectFormatEntity);

    // Validate that we have at least one column specified in the business object format schema.
    Assert.notEmpty(businessObjectFormat.getSchema().getColumns(),
            String.format("No schema columns specified for business object format {%s}.",
                    dmDaoHelper.businessObjectFormatEntityAltKeyToString(businessObjectFormatEntity)));

    if (isPartitioned) {
        // Validate that we have at least one partition column specified in the business object format schema.
        Assert.notEmpty(businessObjectFormat.getSchema().getPartitions(),
                String.format("No schema partitions specified for business object format {%s}.",
                        dmDaoHelper.businessObjectFormatEntityAltKeyToString(businessObjectFormatEntity)));

        // Validate that partition column names do not contain '/' characters.
        for (SchemaColumn partitionColumn : businessObjectFormat.getSchema().getPartitions()) {
            Assert.doesNotContain(partitionColumn.getName(), "/", String.format(
                    "Partition column name \"%s\" can not contain a '/' character. Business object format: {%s}",
                    partitionColumn.getName(),
                    dmDaoHelper.businessObjectFormatEntityAltKeyToString(businessObjectFormatEntity)));
        }
    }

    // Add drop table if requested.
    if (includeDropTableStatement != null && includeDropTableStatement) {
        sb.append(String.format("DROP TABLE IF EXISTS `%s`;\n\n", tableName));
    }

    // Depending on the flag, prepare "if not exists" option text or leave it an empty string.
    String ifNotExistsOption = includeIfNotExistsOption != null && includeIfNotExistsOption ? "IF NOT EXISTS "
            : "";

    // Only generate the create table DDL statement, if custom DDL was not specified.
    if (customDdlEntity == null) {
        generateStandardBaseDdl(businessObjectFormatEntity, isPartitioned, tableName, sb, businessObjectFormat,
                ifNotExistsOption);
    } else {
        // Use the custom DDL in place of the create table statement.
        sb.append(String.format("%s\n\n", customDdlEntity.getDdl()));

        // We need to substitute the relative custom DDL token with an actual table name.
        replacements.put(TABLE_NAME_CUSTOM_DDL_TOKEN, tableName);
    }

    // Add alter table statements only if the list of partition filters is not empty - this is applicable to generating DDL for business object data only.
    if (!CollectionUtils.isEmpty(partitionFilters)) {
        processPartitionFiltersForGenerateDdl(businessObjectFormatEntity, customDdlEntity, isPartitioned,
                tableName, allowMissingData, partitionFilters, businessObjectFormatVersion,
                businessObjectDataVersion, storageEntity, s3BucketName, sb, replacements, businessObjectFormat,
                ifNotExistsOption);
    }
    // Add a location statement with a token if this is format dll that does not use custom ddl.
    else if (!isPartitioned && customDdlEntity == null) {
        // Since custom DDL is not specified, there are no partition values, and this table is not partitioned, add a LOCATION clause with a token.
        sb.append(String.format("LOCATION '%s';", NON_PARTITIONED_TABLE_LOCATION_CUSTOM_DDL_TOKEN));
    }

    // Trim to remove unnecessary end-of-line characters, if any, from the end of the generated DDL.
    String resultDdl = sb.toString().trim();

    // For custom DDL, substitute the relative custom DDL tokens with their values.
    if (customDdlEntity != null) {
        for (Map.Entry<String, String> entry : replacements.entrySet()) {
            String token = entry.getKey();
            String value = entry.getValue();
            resultDdl = resultDdl.replaceAll(Pattern.quote(token), value);
        }
    }

    return resultDdl;
}

From source file:org.finra.herd.service.helper.AlternateKeyHelper.java

/**
 * Validates and returns a trimmed alternate key parameter value.
 *
 * @param indefiniteArticle the indefinite article to use with the specified parameter name
 * @param parameterName the alternate key parameter name
 * @param parameterValue the alternate key parameter value
 *
 * @return the trimmed alternate key parameter value
 * @throws IllegalArgumentException if alternate key parameter is missing or not valid
 *///from ww w  .  j a va 2s . co m
public String validateStringParameter(String indefiniteArticle, String parameterName, String parameterValue)
        throws IllegalArgumentException {
    Assert.hasText(parameterValue, String.format("%s %s must be specified.", indefiniteArticle, parameterName));
    Assert.doesNotContain(parameterValue, "/", String.format("%s can not contain a forward slash character.",
            StringUtils.capitalize(parameterName)));
    return parameterValue.trim();
}

From source file:org.finra.herd.service.helper.Hive13DdlGenerator.java

/**
 * Generates and append to the string builder the create table Hive 13 DDL as per specified parameters.
 *///w w w  .j  av a  2s  . c  o m
private String generateCreateTableDdlHelper(GenerateDdlRequest generateDdlRequest) {
    // TODO: We might want to consider using a template engine such as Velocity to generate this DDL so we don't wind up just doing string manipulation.

    StringBuilder sb = new StringBuilder();

    // For custom DDL, we would need to substitute the custom DDL tokens with their relative values.
    HashMap<String, String> replacements = new HashMap<>();

    // Validate that partition values passed in the list of partition filters do not contain '/' character.
    if (generateDdlRequest.isPartitioned && !CollectionUtils.isEmpty(generateDdlRequest.partitionFilters)) {
        // Validate that partition values do not contain '/' characters.
        for (List<String> partitionFilter : generateDdlRequest.partitionFilters) {
            for (String partitionValue : partitionFilter) {
                Assert.doesNotContain(partitionValue, "/", String
                        .format("Partition value \"%s\" can not contain a '/' character.", partitionValue));
            }
        }
    }

    // Get business object format model object to directly access schema columns and partitions.
    BusinessObjectFormat businessObjectFormat = businessObjectFormatHelper
            .createBusinessObjectFormatFromEntity(generateDdlRequest.businessObjectFormatEntity);

    // Validate that we have at least one column specified in the business object format schema.
    assertSchemaColumnsNotEmpty(businessObjectFormat, generateDdlRequest.businessObjectFormatEntity);

    if (generateDdlRequest.isPartitioned) {
        // Validate that we have at least one partition column specified in the business object format schema.
        Assert.notEmpty(businessObjectFormat.getSchema().getPartitions(),
                String.format("No schema partitions specified for business object format {%s}.",
                        businessObjectFormatHelper.businessObjectFormatEntityAltKeyToString(
                                generateDdlRequest.businessObjectFormatEntity)));

        // Validate that partition column names do not contain '/' characters.
        for (SchemaColumn partitionColumn : businessObjectFormat.getSchema().getPartitions()) {
            Assert.doesNotContain(partitionColumn.getName(), "/", String.format(
                    "Partition column name \"%s\" can not contain a '/' character. Business object format: {%s}",
                    partitionColumn.getName(),
                    businessObjectFormatHelper.businessObjectFormatEntityAltKeyToString(
                            generateDdlRequest.businessObjectFormatEntity)));
        }
    }

    // Add drop table if requested.
    if (BooleanUtils.isTrue(generateDdlRequest.includeDropTableStatement)) {
        sb.append(String.format("DROP TABLE IF EXISTS `%s`;\n\n", generateDdlRequest.tableName));
    }

    // Depending on the flag, prepare "if not exists" option text or leave it an empty string.
    String ifNotExistsOption = BooleanUtils.isTrue(generateDdlRequest.includeIfNotExistsOption)
            ? "IF NOT EXISTS "
            : "";

    // Only generate the create table DDL statement, if custom DDL was not specified.
    if (generateDdlRequest.customDdlEntity == null) {
        generateStandardBaseDdl(generateDdlRequest, sb, businessObjectFormat, ifNotExistsOption);
    } else {
        // Use the custom DDL in place of the create table statement.
        sb.append(String.format("%s\n\n", generateDdlRequest.customDdlEntity.getDdl()));

        // We need to substitute the relative custom DDL token with an actual table name.
        replacements.put(TABLE_NAME_CUSTOM_DDL_TOKEN, generateDdlRequest.tableName);
    }

    // Add alter table statements only if the list of partition filters is not empty - this is applicable to generating DDL for business object data only.
    if (!CollectionUtils.isEmpty(generateDdlRequest.partitionFilters)) {
        processPartitionFiltersForGenerateDdl(generateDdlRequest, sb, replacements, businessObjectFormat,
                ifNotExistsOption);
    }
    // Add a location statement with a token if this is format dll that does not use custom ddl.
    else if (!generateDdlRequest.isPartitioned && generateDdlRequest.customDdlEntity == null) {
        // Since custom DDL is not specified, there are no partition values, and this table is not partitioned, add a LOCATION clause with a token.
        sb.append(String.format("LOCATION '%s';", NON_PARTITIONED_TABLE_LOCATION_CUSTOM_DDL_TOKEN));
    }

    // Trim to remove unnecessary end-of-line characters, if any, from the end of the generated DDL.
    String resultDdl = sb.toString().trim();

    // For custom DDL, substitute the relative custom DDL tokens with their values.
    if (generateDdlRequest.customDdlEntity != null) {
        for (Map.Entry<String, String> entry : replacements.entrySet()) {
            String token = entry.getKey();
            String value = entry.getValue();
            resultDdl = resultDdl.replaceAll(Pattern.quote(token), value);
        }
    }

    return resultDdl;
}